RIP-seq.Rmd 77.4 KB
Newer Older
Venkat Malladi's avatar
Venkat Malladi committed
1 2 3 4 5 6 7 8 9 10
RIP-seq full analysis
=====================================
## Setup and Imports
```{r init}
source("http://bioconductor.org/biocLite.R")
biocLite("GenomicFeatures")
biocLite("groHMM")
biocLite("org.Hs.eg.db")
biocLite("edgeR")
biocLite("TxDb.Hsapiens.UCSC.hg19.knownGene")
Venkat Malladi's avatar
Venkat Malladi committed
11
biocLite("BSgenome.Hsapiens.UCSC.hg19")
Venkat Malladi's avatar
Venkat Malladi committed
12 13 14 15 16 17 18 19 20 21 22 23 24
biocLite("goseq")
install.packages("ggplot2")
install.packages("VennDiagram")
install.packages("reshape")
library(groHMM)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
library(edgeR)
library(org.Hs.eg.db)
library(GenomicAlignments)
library(GenomicFeatures)
library(ggplot2)
library(VennDiagram)
library(reshape)
Venkat Malladi's avatar
Venkat Malladi committed
25
library(BSgenome.Hsapiens.UCSC.hg19)
Venkat Malladi's avatar
Venkat Malladi committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
```

## Functions
```{r functions}
reverseStrandGA <- function(ga) {
    temp <- ga
    strand(temp[as.character(strand(ga)) == "+",]) <- "-"
    strand(temp[as.character(strand(ga)) == "-",]) <- "+"
    return(temp)
}

readBam <- function(bam_file, reverse=TRUE) {
    #print(sam)
    bam <- file.path(bam_file)
    reads <-  as(readGAlignments(bam), "GRanges")

    gr <- granges(reads)
    gr <- sortSeqlevels(gr)
    #print(paste("Lib:", NROW(gr)), quote=FALSE)
    if (reverse)
        reads <- reverseStrandGA(reads)

    return(reads)
}

countReads <- function(anno, sam, snrna_anno, removeSNORNA=TRUE) {
    bam <- readBam(sam, reverse=TRUE)
    lib <- NROW(bam)

    if (removeSNORNA) {
        o <- findOverlaps(bam, snrna_anno)
        bam <- bam[-unique(queryHits(o)),]
    }

    counts <- countOverlaps(anno, bam)
    return(list(lib=lib, counts=counts))
}

CountRefseq <- function(anno, sam, snrna_anno, removeSNORNA=TRUE) {
    cnt1 <- countReads(anno=anno, sam=sam, snrna_anno=snrna_anno, removeSNORNA=removeSNORNA)
    cnt2 <- countReads(anno=reduce(anno), sam=sam, snrna_anno=snrna_anno, removeSNORNA=removeSNORNA)
    return(cnt1)
}


CountSNRNA <- function(anno, sam) {
    cnt <- countReads(anno=anno, sam=sam, removeSNORNA=FALSE)
    return(cnt)
}

```


## Transcripts
```{r transcripts}
## Load Annotation File
82
pc_file <- file.path("reference_annotations", "ucsc_refseq_genes.gtf")
Venkat Malladi's avatar
Venkat Malladi committed
83 84 85
txdb <- makeTxDbFromGFF(pc_file, format="gtf")
pc_tx <- transcripts(txdb, columns=c("GENEID", "TXID", "TXNAME"))

86
pc_mapping <- read.csv("reference_annotations/refseq_mapping.txt", header=T, sep='\t')
Venkat Malladi's avatar
Venkat Malladi committed
87 88 89 90 91 92 93 94
pc_inx <- match(unlist(mcols(pc_tx)$TXNAME), pc_mapping$name)
mcols(pc_tx)$gene_name <- as.character(pc_mapping[pc_inx,"name2"])


seqlevels(pc_tx,force=TRUE) <- c("chr1","chr2","chr3","chr4","chr5","chr6","chr7","chr8","chr9", "chr10", "chr11", "chr12","chr13", "chr14", "chr15","chr16", "chr17", "chr18","chr19", "chr20", "chr21","chr22", "chrX","chrY" )   
names(mcols(pc_tx)) <- c("gene_id", "tx_id", "tx_name","gene_name")
ref_tx <- pc_tx[grep("NM_*",mcols(pc_tx)$gene_id)]

95 96
ref_transcripts <- NROW(unique(unlist(mcols(ref_tx)$gene_id)))
ref_genes <- NROW(unique(unlist(mcols(ref_tx)$gene_name)))
Venkat Malladi's avatar
Venkat Malladi committed
97

98
lnc_file <- file.path("reference_annotations", "lncipedia_4_0_hg19.gtf")
Venkat Malladi's avatar
Venkat Malladi committed
99 100 101 102 103
txdb <- makeTxDbFromGFF(lnc_file, format="gtf")
lnc_tx <- transcripts(txdb, columns=c("GENEID", "TXID", "TXNAME"))
names(mcols(lnc_tx)) <- c("gene_id", "tx_id", "tx_name")
seqlevels(lnc_tx,force=TRUE) <- c("chr1","chr2","chr3","chr4","chr5","chr6","chr7","chr8","chr9", "chr10", "chr11", "chr12","chr13", "chr14", "chr15","chr16", "chr17", "chr18","chr19", "chr20", "chr21","chr22", "chrX","chrY" )  

104 105
lnc_transcripts <- NROW(unique(unlist(mcols(lnc_tx)$tx_name)))
lnc_genes <- NROW(unique(unlist(mcols(lnc_tx)$gene_id)))
Venkat Malladi's avatar
Venkat Malladi committed
106

107
sn_file <- file.path("reference_annotations", "gencode.v19.annotation_snRNA.gtf")
Venkat Malladi's avatar
Venkat Malladi committed
108 109 110 111 112
txdb <- makeTxDbFromGFF(sn_file, format="gtf")
sn_tx <- transcripts(txdb, columns=c("GENEID", "TXID", "TXNAME"))
names(mcols(sn_tx)) <- c("gene_id", "tx_id", "tx_name")
seqlevels(sn_tx,force=TRUE) <- c("chr1","chr2","chr3","chr4","chr5","chr6","chr7","chr8","chr9", "chr10", "chr11", "chr12","chr13", "chr14", "chr15","chr16", "chr17", "chr18","chr19", "chr20", "chr21","chr22", "chrX","chrY" )  

113 114
sn_transcripts <- NROW(unique(unlist(mcols(sn_tx)$tx_name)))
sn_genes <- NROW(unique(unlist(mcols(sn_tx)$gene_id)))
Venkat Malladi's avatar
Venkat Malladi committed
115

116
sno_file <- file.path("reference_annotations", "gencode.v19.annotation_snoRNA.gtf")
Venkat Malladi's avatar
Venkat Malladi committed
117 118 119 120 121
txdb <- makeTxDbFromGFF(sno_file, format="gtf")
sno_tx <- transcripts(txdb, columns=c("GENEID", "TXID", "TXNAME"))
names(mcols(sno_tx)) <- c("gene_id", "tx_id", "tx_name")
seqlevels(sno_tx,force=TRUE) <- c("chr1","chr2","chr3","chr4","chr5","chr6","chr7","chr8","chr9", "chr10", "chr11", "chr12","chr13", "chr14", "chr15","chr16", "chr17", "chr18","chr19", "chr20", "chr21","chr22", "chrX","chrY" )  

122 123
sno_transcripts <- NROW(unique(unlist(mcols(sno_tx)$tx_name)))
sno_genes <- NROW(unique(unlist(mcols(sno_tx)$gene_id)))
Venkat Malladi's avatar
Venkat Malladi committed
124

125
all_sn_file <- file.path("reference_annotations", "gencode.v19.annotation_all_snRNA.gtf")
Venkat Malladi's avatar
Venkat Malladi committed
126 127 128 129 130 131
txdb <- makeTxDbFromGFF(all_sn_file, format="gtf")
all_sn_tx <- transcripts(txdb, columns=c("GENEID", "TXID", "TXNAME"))
names(mcols(all_sn_tx)) <- c("gene_id", "tx_id", "tx_name")
seqlevels(all_sn_tx,force=TRUE) <- c("chr1","chr2","chr3","chr4","chr5","chr6","chr7","chr8","chr9", "chr10", "chr11", "chr12","chr13", "chr14", "chr15","chr16", "chr17", "chr18","chr19", "chr20", "chr21","chr22", "chrX","chrY" )  
```

Venkat Malladi's avatar
Venkat Malladi committed
132
```{r alignments Basal}
Venkat Malladi's avatar
Venkat Malladi committed
133 134 135
MLK_RNA1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RNAseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MLK_RNA1/align-star-se.sh-1.0.0/MLK_RNA1_AGTCAA_L008_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
MLK_RNA2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RNAseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MLK_RNA2/align-star-se.sh-1.0.0/MLK_RNA2_GTCCGC_L008_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"

136 137 138
MPK_RNA1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RNAseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MPK_RNA1/align-star-se.sh-1.0.0/MPK_RNA1_ATGTCA_L004_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
MPK_RNA2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RNAseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MPK_RNA2_secondRun/align-star-se.sh-1.0.0/MPK_RNA2_GTGGCC_L002_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"

Venkat Malladi's avatar
Venkat Malladi committed
139 140 141 142 143 144 145 146 147 148
MLK_RIP_PI1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MLK_RIP1_PI/align-star-se.sh-2.0.0/MLK_RIP1_PI_ACAGTG_L006_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
MLK_RIP_PI2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MLK_RIP2_PI/align-star-se.sh-2.0.0/MLK_RIP2_PI_GTTTCG_L008_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"

MLK_RIP_PARP1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MLK_RIP1_PARP1/align-star-se.sh-2.0.0/MLK_RIP1_PARP1_GCCAAT_L005_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
MLK_RIP_PARP2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MLK_RIP2_PARP1/align-star-se.sh-2.0.0/MLK_RIP2_PARP1_CGTACG_L005_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"

MPK_RIP_PARP1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MPK_RIP1_PARP1/align-star-se.sh-2.0.0/MPK_RIP1_PARP1_TAGCTT_L008_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
MPK_RIP_PARP2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MPK_RIP2_PARP1/align-star-se.sh-2.0.0/MPK_RIP2_PARP1_ATGAGC_L008_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"

```
149

Venkat Malladi's avatar
Venkat Malladi committed
150
```{r counts Basal}
Venkat Malladi's avatar
Venkat Malladi committed
151 152 153 154 155 156 157 158 159 160 161 162
MLK_RNA1_counts_ref <- CountRefseq(ref_tx, MLK_RNA1, all_sn_tx, removeSNORNA=TRUE)
MLK_RNA2_counts_ref <- CountRefseq(ref_tx, MLK_RNA2, all_sn_tx, removeSNORNA=TRUE)

MLK_RNA1_counts_lnc <- CountRefseq(lnc_tx, MLK_RNA1, all_sn_tx, removeSNORNA=TRUE)
MLK_RNA2_counts_lnc <- CountRefseq(lnc_tx, MLK_RNA2, all_sn_tx, removeSNORNA=TRUE)

MLK_RNA1_counts_sn <- CountSNRNA(sn_tx, MLK_RNA1)
MLK_RNA2_counts_sn <- CountSNRNA(sn_tx, MLK_RNA2)

MLK_RNA1_counts_sno <- CountSNRNA(sno_tx, MLK_RNA1)
MLK_RNA2_counts_sno <- CountSNRNA(sno_tx, MLK_RNA2)

163 164 165 166 167 168
MPK_RNA1_counts_sn <- CountSNRNA(sn_tx, MPK_RNA1)
MPK_RNA2_counts_sn <- CountSNRNA(sn_tx, MPK_RNA2)

MPK_RNA1_counts_sno <- CountSNRNA(sno_tx, MPK_RNA1)
MPK_RNA2_counts_sno <- CountSNRNA(sno_tx, MPK_RNA2)

Venkat Malladi's avatar
Venkat Malladi committed
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203

MLK_RIP_PI1_counts_ref <- CountRefseq(ref_tx, MLK_RIP_PI1, all_sn_tx, removeSNORNA=TRUE)
MLK_RIP_PI2_counts_ref <- CountRefseq(ref_tx, MLK_RIP_PI2, all_sn_tx, removeSNORNA=TRUE)

MLK_RIP_PI1_counts_lnc <- CountRefseq(lnc_tx, MLK_RIP_PI1, all_sn_tx, removeSNORNA=TRUE)
MLK_RIP_PI2_counts_lnc <- CountRefseq(lnc_tx, MLK_RIP_PI2, all_sn_tx, removeSNORNA=TRUE)

MLK_RIP_PI1_counts_sn <- CountSNRNA(sn_tx, MLK_RIP_PI1)
MLK_RIP_PI2_counts_sn <- CountSNRNA(sn_tx, MLK_RIP_PI2)

MLK_RIP_PI1_counts_sno <- CountSNRNA(sno_tx, MLK_RIP_PI1)
MLK_RIP_PI2_counts_sno <- CountSNRNA(sno_tx, MLK_RIP_PI2)

MLK_RIP_PARP1_counts_ref <- CountRefseq(ref_tx, MLK_RIP_PARP1, all_sn_tx, removeSNORNA=TRUE)
MLK_RIP_PARP2_counts_ref <- CountRefseq(ref_tx, MLK_RIP_PARP2, all_sn_tx, removeSNORNA=TRUE)

MLK_RIP_PARP1_counts_lnc <- CountRefseq(lnc_tx, MLK_RIP_PARP1, all_sn_tx, removeSNORNA=TRUE)
MLK_RIP_PARP2_counts_lnc <- CountRefseq(lnc_tx, MLK_RIP_PARP2, all_sn_tx, removeSNORNA=TRUE)

MLK_RIP_PARP1_counts_sn <- CountSNRNA(sn_tx, MLK_RIP_PARP1)
MLK_RIP_PARP2_counts_sn <- CountSNRNA(sn_tx, MLK_RIP_PARP2)

MLK_RIP_PARP1_counts_sno <- CountSNRNA(sno_tx, MLK_RIP_PARP1)
MLK_RIP_PARP2_counts_sno <- CountSNRNA(sno_tx, MLK_RIP_PARP2)

MPK_RIP_PARP1_counts_sn <- CountSNRNA(sn_tx, MPK_RIP_PARP1)
MPK_RIP_PARP2_counts_sn <- CountSNRNA(sn_tx, MPK_RIP_PARP2)

MPK_RIP_PARP1_counts_sno <- CountSNRNA(sno_tx, MPK_RIP_PARP1)
MPK_RIP_PARP2_counts_sno <- CountSNRNA(sno_tx, MLK_RIP_PARP2)

```


# RPKM Cutoff
Venkat Malladi's avatar
Venkat Malladi committed
204
``` {r rpkm Basal}
205
# Refseq Genes
Venkat Malladi's avatar
Venkat Malladi committed
206 207 208 209 210
MLK_RNA_counts_ref <- MLK_RNA1_counts_ref$counts +  MLK_RNA2_counts_ref$counts
MLK_RNA_lib_ref <- MLK_RNA1_counts_ref$lib +  MLK_RNA2_counts_ref$lib
MLK_RNA_ref_d <- DGEList(counts=as.matrix(MLK_RNA_counts_ref), lib.size=MLK_RNA_lib_ref)
MLK_RNA_ref_rpkm <- data.frame(rpkm(MLK_RNA_ref_d,width(ref_tx)))
mlk_pc_rpkm <- ref_tx[MLK_RNA_ref_rpkm>=1]
211 212 213

mlk_pc_expressed_transcripts <- NROW(unique(unlist(mcols(mlk_pc_rpkm)$tx_name)))
mlk_pc_expressed_genes <- NROW(unique(unlist(mcols(mlk_pc_rpkm)$gene_name)))
Venkat Malladi's avatar
Venkat Malladi committed
214 215 216 217 218 219 220 221 222 223 224 225 226


MLK_RIP_PARP_counts_ref <- MLK_RIP_PARP1_counts_ref$counts +  MLK_RIP_PARP2_counts_ref$counts
MLK_RIP_PARP_lib_ref <- MLK_RIP_PARP1_counts_ref$lib +  MLK_RIP_PARP2_counts_ref$lib
MLK_RIP_PI_counts_ref <- MLK_RIP_PI1_counts_ref$counts +  MLK_RIP_PI2_counts_ref$counts
MLK_RIP_PI_lib_ref <- MLK_RIP_PI1_counts_ref$lib +  MLK_RIP_PI1_counts_ref$lib
MLK_RIP_PI_d <- DGEList(counts=as.matrix(MLK_RIP_PI_counts_ref), lib.size=MLK_RIP_PI_lib_ref)
MLK_RIP_PI_rpkm <- data.frame(rpkm(MLK_RIP_PI_d,width(ref_tx)))
MLK_RIP_PARP_d <- DGEList(counts=as.matrix(MLK_RIP_PARP_counts_ref), lib.size=MLK_RIP_PARP_lib_ref)
MLK_RIP_PARP_rpkm <- data.frame(rpkm(MLK_RIP_PARP_d,width(ref_tx)))

MLK_RIP_FC <- data.frame((MLK_RIP_PARP_rpkm+1)/(MLK_RIP_PI_rpkm+1))
mlk_pc_rpkm_fc <- ref_tx[MLK_RNA_ref_rpkm>=1 & MLK_RIP_FC>=2 ]
227 228 229

mlk_pc_bound_transcripts <- NROW(unique(unlist(mcols(mlk_pc_rpkm_fc)$tx_name)))
mlk_pc_bound_genes <- NROW(unique(unlist(mcols(mlk_pc_rpkm_fc)$gene_name)))
Venkat Malladi's avatar
Venkat Malladi committed
230 231
pc_ratio <- NROW(unique(unlist(mcols(mlk_pc_rpkm_fc)$gene_name)))/NROW(unique(unlist(mcols(mlk_pc_rpkm)$gene_name)))

232
# LncRNA Genes
Venkat Malladi's avatar
Venkat Malladi committed
233 234 235 236 237
MLK_RNA_counts_lnc <- MLK_RNA1_counts_lnc$counts +  MLK_RNA2_counts_lnc$counts
MLK_RNA_lib_lnc <- MLK_RNA1_counts_lnc$lib +  MLK_RNA2_counts_lnc$lib
MLK_RNA_lnc_d <- DGEList(counts=as.matrix(MLK_RNA_counts_lnc), lib.size=MLK_RNA_lib_lnc)
MLK_RNA_lnc_rpkm <- data.frame(rpkm(MLK_RNA_lnc_d,width(lnc_tx)))
mlk_lnc_rpkm <- lnc_tx[MLK_RNA_lnc_rpkm>=1]
238 239 240

mlk_lnc_expressed_transcripts <- NROW(unique(unlist(mcols(mlk_lnc_rpkm)$tx_name)))
mlk_lnc_expressed_genes <- NROW(unique(unlist(mcols(mlk_lnc_rpkm)$gene_id)))
Venkat Malladi's avatar
Venkat Malladi committed
241 242 243 244 245 246 247 248 249 250 251 252

MLK_RIP_PARP_counts_lnc <- MLK_RIP_PARP1_counts_lnc$counts +  MLK_RIP_PARP2_counts_lnc$counts
MLK_RIP_PARP_lib_lnc<- MLK_RIP_PARP1_counts_lnc$lib +  MLK_RIP_PARP2_counts_lnc$lib
MLK_RIP_PI_counts_lnc <- MLK_RIP_PI1_counts_lnc$counts +  MLK_RIP_PI2_counts_lnc$counts
MLK_RIP_PI_lib_lnc <- MLK_RIP_PI1_counts_lnc$lib +  MLK_RIP_PI1_counts_lnc$lib
MLK_RIP_PI_d <- DGEList(counts=as.matrix(MLK_RIP_PI_counts_lnc), lib.size=MLK_RIP_PI_lib_lnc)
MLK_RIP_PI_rpkm <- data.frame(rpkm(MLK_RIP_PI_d,width(lnc_tx)))
MLK_RIP_PARP_d <- DGEList(counts=as.matrix(MLK_RIP_PARP_counts_lnc), lib.size=MLK_RIP_PARP_lib_lnc)
MLK_RIP_PARP_rpkm <- data.frame(rpkm(MLK_RIP_PARP_d,width(lnc_tx)))

MLK_RIP_FC <- data.frame((MLK_RIP_PARP_rpkm+1)/(MLK_RIP_PI_rpkm+1))
mlk_lnc_rpkm_fc <- lnc_tx[MLK_RNA_lnc_rpkm>=1 & MLK_RIP_FC>=2 ]
253 254 255

mlk_lnc_bound_transcripts <- NROW(unique(unlist(mcols(mlk_lnc_rpkm_fc)$tx_name)))
mlk_lnc_bound_genes <- NROW(unique(unlist(mcols(mlk_lnc_rpkm_fc)$gene_id)))
Venkat Malladi's avatar
Venkat Malladi committed
256 257
lnc_ratio <- NROW(unique(unlist(mcols(mlk_lnc_rpkm_fc)$gene_id)))/NROW(unique(unlist(mcols(mlk_lnc_rpkm)$gene_id)))

258
# SnoRNA Genes
Venkat Malladi's avatar
Venkat Malladi committed
259 260 261 262 263
MLK_RNA_counts_sno <- MLK_RNA1_counts_sno$counts +  MLK_RNA2_counts_sno$counts
MLK_RNA_lib_sno <- MLK_RNA1_counts_sno$lib +  MLK_RNA1_counts_sno$lib
MLK_RNA_sno_d <- DGEList(counts=as.matrix(MLK_RNA_counts_sno), lib.size=MLK_RNA_lib_sno)
MLK_RNA_sno_rpkm <- data.frame(rpkm(MLK_RNA_sno_d,width(sno_tx)))
mlk_sno_rpkm <- sno_tx[MLK_RNA_sno_rpkm>=1]
264 265

mlk_sno_expressed_transcripts <- NROW(unique(unlist(mcols(mlk_sno_rpkm)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
266 267 268 269 270 271 272 273 274

MLK_RIP_PARP_counts_sno <- MLK_RIP_PARP1_counts_sno$counts +  MLK_RIP_PARP2_counts_sno$counts
MLK_RIP_PARP_lib_sno<- MLK_RIP_PARP1_counts_sno$lib +  MLK_RIP_PARP2_counts_sno$lib
MLK_RIP_PI_counts_sno <- MLK_RIP_PI1_counts_sno$counts +  MLK_RIP_PI2_counts_sno$counts
MLK_RIP_PI_lib_sno <- MLK_RIP_PI1_counts_sno$lib +  MLK_RIP_PI1_counts_sno$lib
MLK_RIP_PI_d <- DGEList(counts=as.matrix(MLK_RIP_PI_counts_sno), lib.size=MLK_RIP_PI_lib_sno)
MLK_RIP_PI_rpkm <- data.frame(rpkm(MLK_RIP_PI_d,width(sno_tx)))
MLK_RIP_PARP_d <- DGEList(counts=as.matrix(MLK_RIP_PARP_counts_sno), lib.size=MLK_RIP_PARP_lib_sno)
MLK_RIP_PARP_rpkm <- data.frame(rpkm(MLK_RIP_PARP_d,width(sno_tx)))
Venkat Malladi's avatar
Venkat Malladi committed
275
MLK_RIP_PARP_rpkm_sno <- MLK_RIP_PARP_rpkm
Venkat Malladi's avatar
Venkat Malladi committed
276 277 278

MLK_RIP_FC <- data.frame((MLK_RIP_PARP_rpkm+1)/(MLK_RIP_PI_rpkm+1))
mlk_sno_rpkm_fc <- sno_tx[MLK_RNA_sno_rpkm>=1 & MLK_RIP_FC>=2 ]
279 280

mlk_sno_bound_transcripts <- NROW(unique(unlist(mcols(mlk_sno_rpkm_fc)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
281 282 283 284 285 286
sno_ratio <- NROW(unique(unlist(mcols(mlk_sno_rpkm_fc)$tx_name)))/NROW(unique(unlist(mcols(mlk_sno_rpkm)$tx_name)))

MLK_RIP_sno <- data.frame(MLK_RIP_PI_rpkm,MLK_RIP_PARP_rpkm)
colnames(MLK_RIP_sno) <- c('PI', 'PARP1')
MLK_RIP_sno_rpkm <- MLK_RIP_sno[MLK_RNA_sno_rpkm>=1 & MLK_RIP_FC>=2,]

287
# SnRNA Genes
Venkat Malladi's avatar
Venkat Malladi committed
288 289 290 291 292
MLK_RNA_counts_sn <- MLK_RNA1_counts_sn$counts +  MLK_RNA2_counts_sn$counts
MLK_RNA_lib_sn <- MLK_RNA1_counts_sn$lib +  MLK_RNA1_counts_sn$lib
MLK_RNA_sn_d <- DGEList(counts=as.matrix(MLK_RNA_counts_sn), lib.size=MLK_RNA_lib_sn)
MLK_RNA_sn_rpkm <- data.frame(rpkm(MLK_RNA_sn_d,width(sn_tx)))
mlk_sn_rpkm <- sn_tx[MLK_RNA_sn_rpkm>=1]
293 294

mlk_sn_expressed_transcripts <- NROW(unique(unlist(mcols(mlk_sn_rpkm)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
295 296 297 298 299 300 301 302 303

MLK_RIP_PARP_counts_sn <- MLK_RIP_PARP1_counts_sn$counts +  MLK_RIP_PARP2_counts_sn$counts
MLK_RIP_PARP_lib_sn<- MLK_RIP_PARP1_counts_sn$lib +  MLK_RIP_PARP2_counts_sn$lib
MLK_RIP_PI_counts_sn <- MLK_RIP_PI1_counts_sn$counts +  MLK_RIP_PI2_counts_sn$counts
MLK_RIP_PI_lib_sn <- MLK_RIP_PI1_counts_sn$lib +  MLK_RIP_PI1_counts_sn$lib
MLK_RIP_PI_d <- DGEList(counts=as.matrix(MLK_RIP_PI_counts_sn), lib.size=MLK_RIP_PI_lib_sn)
MLK_RIP_PI_rpkm <- data.frame(rpkm(MLK_RIP_PI_d,width(sn_tx)))
MLK_RIP_PARP_d <- DGEList(counts=as.matrix(MLK_RIP_PARP_counts_sn), lib.size=MLK_RIP_PARP_lib_sn)
MLK_RIP_PARP_rpkm <- data.frame(rpkm(MLK_RIP_PARP_d,width(sn_tx)))
Venkat Malladi's avatar
Venkat Malladi committed
304
MLK_RIP_PARP_rpkm_sn <- MLK_RIP_PARP_rpkm
Venkat Malladi's avatar
Venkat Malladi committed
305 306 307 308

MLK_RIP_FC <- data.frame((MLK_RIP_PARP_rpkm+1)/(MLK_RIP_PI_rpkm+1))
mlk_sn_rpkm_fc <- sn_tx[MLK_RNA_sn_rpkm>=1 & MLK_RIP_FC>=2 ]

309
mlk_sn_bound_transcripts <- NROW(unique(unlist(mcols(mlk_sn_rpkm_fc)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
310 311
sn_ratio <- NROW(unique(unlist(mcols(mlk_sn_rpkm_fc)$tx_name)))/NROW(unique(unlist(mcols(mlk_sn_rpkm)$tx_name)))

312 313 314 315
MLK_RIP_sn <- data.frame(MLK_RIP_PI_rpkm,MLK_RIP_PARP_rpkm)
colnames(MLK_RIP_sn) <- c('PI', 'PARP1')
MLK_RIP_sn_rpkm <- MLK_RIP_sn[MLK_RNA_sn_rpkm>=1 & MLK_RIP_FC>=2,]

Venkat Malladi's avatar
Venkat Malladi committed
316
allsno <- c(mlk_sno_rpkm_fc,mlk_sn_rpkm_fc)
317
allsno_rpkm <- rbind(MLK_RIP_sno_rpkm,MLK_RIP_sn_rpkm)
Venkat Malladi's avatar
Venkat Malladi committed
318 319
allsno_rna <- c(sno_tx,sn_tx)
allsno_rna_rpkm <- rbind(MLK_RNA_sno_rpkm,MLK_RNA_sn_rpkm)
Venkat Malladi's avatar
Venkat Malladi committed
320

321
# bar plot (Figure 1C)
Venkat Malladi's avatar
Venkat Malladi committed
322
# Grouped Bar Plot
323
jpeg('figures/barchart-mcf-7-basal-species.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
324
ratios <- c(pc_ratio,lnc_ratio,sno_ratio,sn_ratio)
325
barplot(ratios, main="SNORNA MCF-7 Basal", col=c("red","black", "dimgrey", "lightgrey"),ylim=c(0,.6))
Venkat Malladi's avatar
Venkat Malladi committed
326 327 328 329 330
dev.off()

boundTesting <-matrix(c(952,5471,205,239),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("mRNA", "snoRNA")))
fisher.test(boundTesting)

331 332 333 334 335 336
boundTesting <-matrix(c(2461,7406,205,239),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("lncRNA", "snoRNA")))
fisher.test(boundTesting)

boundTesting <-matrix(c(284,199,205,239),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("snRNA", "snoRNA")))
fisher.test(boundTesting)

337 338
# Boxplot of Preimmune vs PARP-1 (Figure 1D)
jpeg('figures/boxplot-mcf-7-basal-species.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
339 340 341
boxplot(MLK_RIP_sno_rpkm,col=(c("orange","blue")),outline=FALSE,ylim = c(0,400),yaxt="n", cex.axis=1,las=2,lwd=4,lty=1)
axis(2, at=seq(0,400,100))
dev.off()
342

Venkat Malladi's avatar
Venkat Malladi committed
343 344 345
wilcox.test(MLK_RIP_sno_rpkm[,1], MLK_RIP_sno_rpkm[,2],paired=T)


346
# Get Categories of  snoRNA
Venkat Malladi's avatar
Venkat Malladi committed
347 348 349 350 351 352 353
mlk_gr_snotx <- data.frame(seqnames=seqnames(mlk_sno_rpkm),
  starts=start(mlk_sno_rpkm)-1,
  ends=end(mlk_sno_rpkm),
  strand=strand(mlk_sno_rpkm),
  tx_name = elementMetadata(mlk_sno_rpkm)$tx_name,
  gene_id = unlist(elementMetadata(mlk_sno_rpkm)$gene_id))

354
sno_annotations <- read.table('reference_annotations/RNA_small_nucleolar.txt',header = TRUE, sep = "\t")
Venkat Malladi's avatar
Venkat Malladi committed
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
sno_inx <- match(matrix(unlist(strsplit(as.character(mlk_gr_snotx$gene_id),split='.',fixed=T)),ncol=2,byrow=T)[,1], sno_annotations$ensembl_gene_id)
mlk_gr_snotx$symbol <- as.character(sno_annotations[sno_inx,"symbol"])
mlk_gr_snotx$gene_family <- as.character(sno_annotations[sno_inx,"gene_family"])
mlk_gr_snotx$gene_family[mlk_gr_snotx$gene_family == "Small nucleolar RNAs, H/ACA box"] <- "H/ACA box"
mlk_gr_snotx$gene_family[mlk_gr_snotx$gene_family == "Small nucleolar RNAs, C/D box"] <- "C/D box"
mlk_gr_snotx$gene_family[mlk_gr_snotx$gene_family == "Small Cajal body-specific RNAs"] <- "scaRNA"
mlk_gr_snotx$gene_family[mlk_gr_snotx$gene_family == ""] <- "Other"
mlk_gr_snotx$gene_family[is.na(mlk_gr_snotx$gene_family)] <- "Other"

ha_rna <- dim(mlk_gr_snotx[mlk_gr_snotx$gene_family == "H/ACA box",])[1]
cd_rna <- dim(mlk_gr_snotx[mlk_gr_snotx$gene_family == "C/D box",])[1]
sc_rna <- dim(mlk_gr_snotx[mlk_gr_snotx$gene_family == "scaRNA",])[1]

dat = data.frame(count=c(ha_rna, cd_rna, sc_rna), category=c("H/ACA box", "C/D box", "scaRNA"))
dat$fraction = dat$count / sum(dat$count)

dat$ymax = cumsum(dat$fraction)
dat$ymin = c(0, head(dat$ymax, n=-1))

dat$category <- factor(dat$category, levels = c("H/ACA box", "C/D box", "scaRNA"))

376 377
# Pie Chart of Categories of SNORNA (Figure 1E)
jpeg('figures/piechart-mcf-7-basal-species.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
ggplot(dat, aes(fill=category, ymax=ymax, ymin=ymin, xmax=4, xmin=2)) +
  geom_rect(fill=c('darkorchid1', "darkorange1","darkgreen")) +
   coord_polar(theta="y") +
   xlim(c(0, 4)) +
   theme_bw() +
   theme(panel.grid=element_blank()) +
   theme(axis.text=element_blank()) +
   theme(axis.ticks=element_blank())
dev.off()



mlk_gr_snotx <- data.frame(seqnames=seqnames(mlk_sno_rpkm_fc),
  starts=start(mlk_sno_rpkm_fc)-1,
  ends=end(mlk_sno_rpkm_fc),
  strand=strand(mlk_sno_rpkm_fc),
  tx_name = elementMetadata(mlk_sno_rpkm_fc)$tx_name,
  gene_id = unlist(elementMetadata(mlk_sno_rpkm_fc)$gene_id))

sno_inx <- match(matrix(unlist(strsplit(as.character(mlk_gr_snotx$gene_id),split='.',fixed=T)),ncol=2,byrow=T)[,1], sno_annotations$ensembl_gene_id)
mlk_gr_snotx$symbol <- as.character(sno_annotations[sno_inx,"symbol"])
mlk_gr_snotx$gene_family <- as.character(sno_annotations[sno_inx,"gene_family"])
mlk_gr_snotx$gene_family[mlk_gr_snotx$gene_family == "Small nucleolar RNAs, H/ACA box"] <- "H/ACA box"
mlk_gr_snotx$gene_family[mlk_gr_snotx$gene_family == "Small nucleolar RNAs, C/D box"] <- "C/D box"
mlk_gr_snotx$gene_family[mlk_gr_snotx$gene_family == "Small Cajal body-specific RNAs"] <- "scaRNA"
mlk_gr_snotx$gene_family[mlk_gr_snotx$gene_family == ""] <- "Other"
mlk_gr_snotx$gene_family[is.na(mlk_gr_snotx$gene_family)] <- "Other"

ha_rip <- dim(mlk_gr_snotx[mlk_gr_snotx$gene_family == "H/ACA box",])[1]
cd_rip <- dim(mlk_gr_snotx[mlk_gr_snotx$gene_family == "C/D box",])[1]
sc_rip<- dim(mlk_gr_snotx[mlk_gr_snotx$gene_family == "scaRNA",])[1]

410 411
# Bar plot SnoRNA Enrichments (Figure 1F)
jpeg('figures/barchart-mcf-7-basal-species_snospecies.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
412 413 414 415 416 417 418
ratios <- c(sn_ratio,ha_rip/ha_rna,cd_rip/cd_rna,sc_rip/sc_rna)
barplot(ratios, main="snoRNA species MCF-7 Basal", col=c('pink1','darkorchid1', "darkorange1","darkgreen"),ylim=c(0,1))
dev.off()

typeTesting <-matrix(c(63,19,38,76),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("HA", "CD")))
fisher.test(typeTesting)

419 420 421 422 423 424
typeTesting <-matrix(c(63,19,85,199),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("HA", "snRNA")))
fisher.test(typeTesting)

typeTesting <-matrix(c(63,19,15,4),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("HA", "scRNA")))
fisher.test(typeTesting)

425
# Combine snRNA and snoRNA and print out
Venkat Malladi's avatar
Venkat Malladi committed
426 427 428 429 430 431 432 433
allsnotx <- data.frame(seqnames=seqnames(allsno),
  starts=start(allsno)-1,
  ends=end(allsno),
  strand=strand(allsno),
  tx_id = elementMetadata(allsno)$tx_name,
  gene_id = unlist(elementMetadata(allsno)$gene_id))

allsnotx_rpkm <- cbind(allsnotx,allsno_rpkm)
434 435
sno_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snoRNA_mapping.txt", header=F, sep=',')
sn_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snRNA_mapping.txt", header=F, sep=',')
436 437 438 439
gencode_sn_mapping <-rbind(sno_mapping,sn_mapping)
sn_inx <- match(allsnotx_rpkm$tx_id, gencode_sn_mapping$V2)
allsnotx_rpkm$tx_name <- as.character(gencode_sn_mapping[sn_inx,"V4"])
allsnotx_rpkm$gene_name <- as.character(gencode_sn_mapping[sn_inx,"V3"])
Venkat Malladi's avatar
Venkat Malladi committed
440
write.table(allsnotx_rpkm, file="tables/mcf-7-basal-snRNA_RPKM_1_FC_2.tsv", quote=F, sep="\t", row.names=F, col.names=T)
441

Venkat Malladi's avatar
Venkat Malladi committed
442 443 444 445 446 447 448 449
allsnotx_rna <- data.frame(seqnames=seqnames(allsno_rna),
  starts=start(allsno_rna)-1,
  ends=end(allsno_rna),
  strand=strand(allsno_rna),
  tx_id = elementMetadata(allsno_rna)$tx_name,
  gene_id = unlist(elementMetadata(allsno_rna)$gene_id))

allsnotx_rna_rpkm <- cbind(allsnotx_rna,allsno_rna_rpkm)
450 451
sno_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snoRNA_mapping.txt", header=F, sep=',')
sn_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snRNA_mapping.txt", header=F, sep=',')
Venkat Malladi's avatar
Venkat Malladi committed
452 453 454 455
gencode_sn_mapping <-rbind(sno_mapping,sn_mapping)
sn_inx <- match(allsnotx_rna_rpkm$tx_id, gencode_sn_mapping$V2)
allsnotx_rna_rpkm$tx_name <- as.character(gencode_sn_mapping[sn_inx,"V4"])
allsnotx_rna_rpkm$gene_name <- as.character(gencode_sn_mapping[sn_inx,"V3"])
456
write.table(allsnotx_rna_rpkm, file="tables/mcf-7-basal-snRNA_RPKM_RNA.tsv", quote=F, sep="\t", row.names=F, col.names=T)
Venkat Malladi's avatar
Venkat Malladi committed
457

458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490

# Compare PARP-1 KD to normal PARP-1 levels
MPK_RNA_counts_sno <- MPK_RNA1_counts_sno$counts +  MPK_RNA2_counts_sno$counts
MPK_RNA_lib_sno <- MPK_RNA1_counts_sno$lib +  MPK_RNA1_counts_sno$lib
group <- factor(c("MLK", "MPK"))
MPK_RNA_sno_d <- DGEList(counts=as.matrix(data.frame(MLK_RNA_counts_sno,MPK_RNA_counts_sno)), lib.size=c(MLK_RNA_lib_sno,MPK_RNA_lib_sno),group=group)
MPK_RNA_sno_rpkm <- data.frame(rpkm(MPK_RNA_sno_d,width(sno_tx)))


MPK_RIP_PARP_rpkm <- data.frame(rpkm(MPK_RIP_PARP_d,width(sno_tx)))
MLK_RIP_PARP_counts_sno <- MLK_RIP_PARP1_counts_sno$counts +  MLK_RIP_PARP2_counts_sno$counts
MLK_RIP_PARP_lib_sno<- MLK_RIP_PARP1_counts_sno$lib +  MLK_RIP_PARP2_counts_sno$lib
MLK_RIP_PI_counts_sno <- MLK_RIP_PI1_counts_sno$counts +  MLK_RIP_PI2_counts_sno$counts
MLK_RIP_PI_lib_sno <- MLK_RIP_PI1_counts_sno$lib +  MLK_RIP_PI1_counts_sno$lib
MLK_RIP_PI_d <- DGEList(counts=as.matrix(MLK_RIP_PI_counts_sno), lib.size=MLK_RIP_PI_lib_sno)
MLK_RIP_PI_rpkm <- data.frame(rpkm(MLK_RIP_PI_d,width(sno_tx)))
MLK_RIP_PARP_d <- DGEList(counts=as.matrix(MLK_RIP_PARP_counts_sno), lib.size=MLK_RIP_PARP_lib_sno)
MLK_RIP_PARP_rpkm <- data.frame(rpkm(MLK_RIP_PARP_d,width(sno_tx)))


MPK_RIP_PARP_counts_sno <- MPK_RIP_PARP1_counts_sno$counts +  MPK_RIP_PARP2_counts_sno$counts
MPK_RIP_PARP_lib_sno<- MPK_RIP_PARP1_counts_sno$lib +  MPK_RIP_PARP2_counts_sno$lib
group <- factor(c("MLK", "MPK"))
MPK_RIP_PARP_d <- DGEList(counts=as.matrix(data.frame(MLK_RIP_PARP_counts_sno,MPK_RIP_PARP_counts_sno)), lib.size=c(MLK_RIP_PARP_lib_sno,MPK_RIP_PARP_lib_sno),group=group)
MPK_RIP_sno_rpkm <- data.frame(rpkm(MPK_RIP_PARP_d,width(sno_tx)))

MLK_RIP_FC <- data.frame((MLK_RIP_PARP_rpkm+1)/(MLK_RIP_PI_rpkm+1))

MPK_RNA_sno_rpkm_filtered <- MPK_RNA_sno_rpkm[MPK_RNA_sno_rpkm$MLK_RNA_counts_sno>=1 & MLK_RIP_FC>=2,]
MPK_RIP_sno_rpkm_filtered <- MPK_RIP_sno_rpkm[MPK_RNA_sno_rpkm$MLK_RNA_counts_sno>=1 & MLK_RIP_FC>=2,]

MPK_enrichment <- (MPK_RIP_sno_rpkm_filtered+0.1)/(MPK_RNA_sno_rpkm_filtered+0.1)

491 492
# Boxplot of PARP-1 vs PARP-1kd
jpeg('figures/boxplot-mcf-7-basal-species_parpkd.jpg')
493 494 495
boxplot(MPK_enrichment,col=(c("blue","yellow")),outline=FALSE,ylim = c(0,25),yaxt="n", cex.axis=1,las=2,lwd=4,lty=1)
axis(2, at=seq(0,25,5))
dev.off()
496

497 498
wilcox.test(MPK_enrichment[,1], MPK_enrichment[,2],paired=T)

Venkat Malladi's avatar
Venkat Malladi committed
499
```
Venkat Malladi's avatar
Venkat Malladi committed
500 501

```{r alignments Estrogen}
Venkat Malladi's avatar
Venkat Malladi committed
502 503
MLKE_RNA1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RNAseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MLKE_RNA1/align-star-se.sh-1.0.0/MLKE_RNA1_AGTTCC_L008_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
MLKE_RNA2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RNAseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MLKE_RNA2/align-star-se.sh-1.0.0/MLKE_RNA2_GTGAAA_L008_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
Venkat Malladi's avatar
Venkat Malladi committed
504

Venkat Malladi's avatar
Venkat Malladi committed
505 506
MLKE_RIP_PI1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MLKE_RIP1_PI/align-star-se.sh-2.0.0/MLKE_RIP1_PI_CAGATC_L006_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
MLKE_RIP_PI2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MLKE_RIP2_PI/align-star-se.sh-2.0.0/MLKE_RIP2_PI_GAGTGG_L008_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
Venkat Malladi's avatar
Venkat Malladi committed
507

Venkat Malladi's avatar
Venkat Malladi committed
508 509
MLKE_RIP_PARP1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MLKE_RIP1_PARP1_SecondRun/align-star-se.sh-2.0.0/MLKE_RIP1_PARP1_ACTTGA_L004_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
MLKE_RIP_PARP2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_MLKE_RIP2_PARP1_16/align-star-se.sh-2.0.0/MLKE_RIP2_PARP1_16_CCGTCC_L007_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
Venkat Malladi's avatar
Venkat Malladi committed
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
```

```{r counts Estrogen}
MLKE_RNA1_counts_ref <- CountRefseq(ref_tx, MLKE_RNA1, all_sn_tx, removeSNORNA=TRUE)
MLKE_RNA2_counts_ref <- CountRefseq(ref_tx, MLKE_RNA2, all_sn_tx, removeSNORNA=TRUE)

MLKE_RNA1_counts_lnc <- CountRefseq(lnc_tx, MLKE_RNA1, all_sn_tx, removeSNORNA=TRUE)
MLKE_RNA2_counts_lnc <- CountRefseq(lnc_tx, MLKE_RNA2, all_sn_tx, removeSNORNA=TRUE)

MLKE_RNA1_counts_sn <- CountSNRNA(sn_tx, MLKE_RNA1)
MLKE_RNA2_counts_sn <- CountSNRNA(sn_tx, MLKE_RNA2)

MLKE_RNA1_counts_sno <- CountSNRNA(sno_tx, MLKE_RNA1)
MLKE_RNA2_counts_sno <- CountSNRNA(sno_tx, MLKE_RNA2)


MLKE_RIP_PI1_counts_ref <- CountRefseq(ref_tx, MLKE_RIP_PI1, all_sn_tx, removeSNORNA=TRUE)
MLKE_RIP_PI2_counts_ref <- CountRefseq(ref_tx, MLKE_RIP_PI2, all_sn_tx, removeSNORNA=TRUE)

MLKE_RIP_PI1_counts_lnc <- CountRefseq(lnc_tx, MLKE_RIP_PI1, all_sn_tx, removeSNORNA=TRUE)
MLKE_RIP_PI2_counts_lnc <- CountRefseq(lnc_tx, MLKE_RIP_PI2, all_sn_tx, removeSNORNA=TRUE)

MLKE_RIP_PI1_counts_sn <- CountSNRNA(sn_tx, MLKE_RIP_PI1)
MLKE_RIP_PI2_counts_sn <- CountSNRNA(sn_tx, MLKE_RIP_PI2)

MLKE_RIP_PI1_counts_sno <- CountSNRNA(sno_tx, MLKE_RIP_PI1)
MLKE_RIP_PI2_counts_sno <- CountSNRNA(sno_tx, MLKE_RIP_PI2)

MLKE_RIP_PARP1_counts_ref <- CountRefseq(ref_tx, MLKE_RIP_PARP1, all_sn_tx, removeSNORNA=TRUE)
MLKE_RIP_PARP2_counts_ref <- CountRefseq(ref_tx, MLKE_RIP_PARP2, all_sn_tx, removeSNORNA=TRUE)

MLKE_RIP_PARP1_counts_lnc <- CountRefseq(lnc_tx, MLKE_RIP_PARP1, all_sn_tx, removeSNORNA=TRUE)
MLKE_RIP_PARP2_counts_lnc <- CountRefseq(lnc_tx, MLKE_RIP_PARP2, all_sn_tx, removeSNORNA=TRUE)

MLKE_RIP_PARP1_counts_sn <- CountSNRNA(sn_tx, MLKE_RIP_PARP1)
MLKE_RIP_PARP2_counts_sn <- CountSNRNA(sn_tx, MLKE_RIP_PARP2)

MLKE_RIP_PARP1_counts_sno <- CountSNRNA(sno_tx, MLKE_RIP_PARP1)
MLKE_RIP_PARP2_counts_sno <- CountSNRNA(sno_tx, MLKE_RIP_PARP2)


```

# RPKM Cutoff
``` {r rpkm Estrogen}
555
# Refseq Genes
Venkat Malladi's avatar
Venkat Malladi committed
556 557 558 559 560
MLKE_RNA_counts_ref <- MLKE_RNA1_counts_ref$counts +  MLKE_RNA2_counts_ref$counts
MLKE_RNA_lib_ref <- MLKE_RNA1_counts_ref$lib +  MLKE_RNA2_counts_ref$lib
MLKE_RNA_ref_d <- DGEList(counts=as.matrix(MLKE_RNA_counts_ref), lib.size=MLKE_RNA_lib_ref)
MLKE_RNA_ref_rpkm <- data.frame(rpkm(MLKE_RNA_ref_d,width(ref_tx)))
mlke_pc_rpkm <- ref_tx[MLKE_RNA_ref_rpkm>=1]
561 562 563

mlke_pc_expressed_transcripts <- NROW(unique(unlist(mcols(mlke_pc_rpkm)$tx_name)))
mlke_pc_expressed_genes <- NROW(unique(unlist(mcols(mlke_pc_rpkm)$gene_name)))
Venkat Malladi's avatar
Venkat Malladi committed
564 565 566 567 568 569 570 571 572 573 574 575

MLKE_RIP_PARP_counts_ref <- MLKE_RIP_PARP1_counts_ref$counts +  MLKE_RIP_PARP2_counts_ref$counts
MLKE_RIP_PARP_lib_ref <- MLKE_RIP_PARP1_counts_ref$lib +  MLKE_RIP_PARP2_counts_ref$lib
MLKE_RIP_PI_counts_ref <- MLKE_RIP_PI1_counts_ref$counts +  MLKE_RIP_PI2_counts_ref$counts
MLKE_RIP_PI_lib_ref <- MLKE_RIP_PI1_counts_ref$lib +  MLKE_RIP_PI1_counts_ref$lib
MLKE_RIP_PI_d <- DGEList(counts=as.matrix(MLKE_RIP_PI_counts_ref), lib.size=MLKE_RIP_PI_lib_ref)
MLKE_RIP_PI_rpkm <- data.frame(rpkm(MLKE_RIP_PI_d,width(ref_tx)))
MLKE_RIP_PARP_d <- DGEList(counts=as.matrix(MLKE_RIP_PARP_counts_ref), lib.size=MLKE_RIP_PARP_lib_ref)
MLKE_RIP_PARP_rpkm <- data.frame(rpkm(MLKE_RIP_PARP_d,width(ref_tx)))

MLKE_RIP_FC <- data.frame((MLKE_RIP_PARP_rpkm+1)/(MLKE_RIP_PI_rpkm+1))
mlke_pc_rpkm_fc <- ref_tx[MLKE_RNA_ref_rpkm>=1 & MLKE_RIP_FC>=2 ]
576 577 578

mlke_pc_bound_transcripts <- NROW(unique(unlist(mcols(mlke_pc_rpkm_fc)$tx_name)))
mlke_pc_bound_genes <- NROW(unique(unlist(mcols(mlke_pc_rpkm_fc)$gene_name)))
Venkat Malladi's avatar
Venkat Malladi committed
579 580
pc_ratio <- NROW(unique(unlist(mcols(mlke_pc_rpkm_fc)$gene_name)))/NROW(unique(unlist(mcols(mlke_pc_rpkm)$gene_name)))

581
# LncRNA Genes
Venkat Malladi's avatar
Venkat Malladi committed
582 583 584 585 586
MLKE_RNA_counts_lnc <- MLKE_RNA1_counts_lnc$counts +  MLKE_RNA2_counts_lnc$counts
MLKE_RNA_lib_lnc <- MLKE_RNA1_counts_lnc$lib +  MLKE_RNA2_counts_lnc$lib
MLKE_RNA_lnc_d <- DGEList(counts=as.matrix(MLKE_RNA_counts_lnc), lib.size=MLKE_RNA_lib_lnc)
MLKE_RNA_lnc_rpkm <- data.frame(rpkm(MLKE_RNA_lnc_d,width(lnc_tx)))
mlke_lnc_rpkm <- lnc_tx[MLKE_RNA_lnc_rpkm>=1]
587 588 589

mlke_lnc_expressed_transcripts <- NROW(unique(unlist(mcols(mlke_lnc_rpkm)$tx_name)))
mlke_lnc_expressed_genes <- NROW(unique(unlist(mcols(mlke_lnc_rpkm)$gene_id)))
Venkat Malladi's avatar
Venkat Malladi committed
590 591 592 593 594 595 596 597 598 599 600 601 602

MLKE_RIP_PARP_counts_lnc <- MLKE_RIP_PARP1_counts_lnc$counts +  MLKE_RIP_PARP2_counts_lnc$counts
MLKE_RIP_PARP_lib_lnc<- MLKE_RIP_PARP1_counts_lnc$lib +  MLKE_RIP_PARP2_counts_lnc$lib
MLKE_RIP_PI_counts_lnc <- MLKE_RIP_PI1_counts_lnc$counts +  MLKE_RIP_PI2_counts_lnc$counts
MLKE_RIP_PI_lib_lnc <- MLKE_RIP_PI1_counts_lnc$lib +  MLKE_RIP_PI1_counts_lnc$lib
MLKE_RIP_PI_d <- DGEList(counts=as.matrix(MLKE_RIP_PI_counts_lnc), lib.size=MLKE_RIP_PI_lib_lnc)
MLKE_RIP_PI_rpkm <- data.frame(rpkm(MLKE_RIP_PI_d,width(lnc_tx)))
MLKE_RIP_PARP_d <- DGEList(counts=as.matrix(MLKE_RIP_PARP_counts_lnc), lib.size=MLKE_RIP_PARP_lib_lnc)
MLKE_RIP_PARP_rpkm <- data.frame(rpkm(MLKE_RIP_PARP_d,width(lnc_tx)))

MLKE_RIP_FC <- data.frame((MLKE_RIP_PARP_rpkm+1)/(MLKE_RIP_PI_rpkm+1))
mlke_lnc_rpkm_fc <- lnc_tx[MLKE_RNA_lnc_rpkm>=1 & MLKE_RIP_FC>=2 ]

603 604 605
mlke_lnc_bound_transcripts <- NROW(unique(unlist(mcols(mlke_lnc_rpkm_fc)$tx_name)))
mlke_lnc_bound_genes <- NROW(unique(unlist(mcols(mlke_lnc_rpkm_fc)$gene_id)))
lnc_ratio <- NROW(unique(unlist(mcols(mlke_lnc_rpkm_fc)$gene_id)))/NROW(unique(unlist(mcols(mlke_lnc_rpkm)$gene_id)))
Venkat Malladi's avatar
Venkat Malladi committed
606

607
# SNORNA Genes
Venkat Malladi's avatar
Venkat Malladi committed
608 609 610 611 612
MLKE_RNA_counts_sno <- MLKE_RNA1_counts_sno$counts +  MLKE_RNA2_counts_sno$counts
MLKE_RNA_lib_sno <- MLKE_RNA1_counts_sno$lib +  MLKE_RNA1_counts_sno$lib
MLKE_RNA_sno_d <- DGEList(counts=as.matrix(MLKE_RNA_counts_sno), lib.size=MLKE_RNA_lib_sno)
MLKE_RNA_sno_rpkm <- data.frame(rpkm(MLKE_RNA_sno_d,width(sno_tx)))
mlke_sno_rpkm <- sno_tx[MLKE_RNA_sno_rpkm>=1]
613 614

mlke_sno_expressed_transcripts <- NROW(unique(unlist(mcols(mlke_sno_rpkm)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
615 616 617 618 619 620 621 622 623

MLKE_RIP_PARP_counts_sno <- MLKE_RIP_PARP1_counts_sno$counts +  MLKE_RIP_PARP2_counts_sno$counts
MLKE_RIP_PARP_lib_sno<- MLKE_RIP_PARP1_counts_sno$lib +  MLKE_RIP_PARP2_counts_sno$lib
MLKE_RIP_PI_counts_sno <- MLKE_RIP_PI1_counts_sno$counts +  MLKE_RIP_PI2_counts_sno$counts
MLKE_RIP_PI_lib_sno <- MLKE_RIP_PI1_counts_sno$lib +  MLKE_RIP_PI1_counts_sno$lib
MLKE_RIP_PI_d <- DGEList(counts=as.matrix(MLKE_RIP_PI_counts_sno), lib.size=MLKE_RIP_PI_lib_sno)
MLKE_RIP_PI_rpkm <- data.frame(rpkm(MLKE_RIP_PI_d,width(sno_tx)))
MLKE_RIP_PARP_d <- DGEList(counts=as.matrix(MLKE_RIP_PARP_counts_sno), lib.size=MLKE_RIP_PARP_lib_sno)
MLKE_RIP_PARP_rpkm <- data.frame(rpkm(MLKE_RIP_PARP_d,width(sno_tx)))
Venkat Malladi's avatar
Venkat Malladi committed
624
MLKE_RIP_PARP_rpkm_sno <- MLKE_RIP_PARP_rpkm
Venkat Malladi's avatar
Venkat Malladi committed
625 626 627

MLKE_RIP_FC <- data.frame((MLKE_RIP_PARP_rpkm+1)/(MLKE_RIP_PI_rpkm+1))
mlke_sno_rpkm_fc <- sno_tx[MLKE_RNA_sno_rpkm>=1 & MLKE_RIP_FC>=2 ]
628 629

mlke_sno_bound_transcripts <- NROW(unique(unlist(mcols(mlke_sno_rpkm_fc)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
630 631 632 633 634 635
sno_ratio <- NROW(unique(unlist(mcols(mlke_sno_rpkm_fc)$tx_name)))/NROW(unique(unlist(mcols(mlke_sno_rpkm)$tx_name)))

MLKE_RIP_sno <- data.frame(MLKE_RIP_PI_rpkm,MLKE_RIP_PARP_rpkm)
colnames(MLKE_RIP_sno) <- c('PI', 'PARP1')
MLKE_RIP_sno_rpkm <- MLKE_RIP_sno[MLKE_RNA_sno_rpkm>=1 & MLKE_RIP_FC>=2,]

636
# SNRNA Genes
Venkat Malladi's avatar
Venkat Malladi committed
637 638 639 640 641
MLKE_RNA_counts_sn <- MLKE_RNA1_counts_sn$counts +  MLKE_RNA2_counts_sn$counts
MLKE_RNA_lib_sn <- MLKE_RNA1_counts_sn$lib +  MLKE_RNA1_counts_sn$lib
MLKE_RNA_sn_d <- DGEList(counts=as.matrix(MLKE_RNA_counts_sn), lib.size=MLKE_RNA_lib_sn)
MLKE_RNA_sn_rpkm <- data.frame(rpkm(MLKE_RNA_sn_d,width(sn_tx)))
mlke_sn_rpkm <- sn_tx[MLKE_RNA_sn_rpkm>=1]
642 643

mlke_sn_expressed_transcripts <- NROW(unique(unlist(mcols(mlke_sn_rpkm)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
644 645 646 647 648 649 650 651 652

MLKE_RIP_PARP_counts_sn <- MLKE_RIP_PARP1_counts_sn$counts +  MLKE_RIP_PARP2_counts_sn$counts
MLKE_RIP_PARP_lib_sn<- MLKE_RIP_PARP1_counts_sn$lib +  MLKE_RIP_PARP2_counts_sn$lib
MLKE_RIP_PI_counts_sn <- MLKE_RIP_PI1_counts_sn$counts +  MLKE_RIP_PI2_counts_sn$counts
MLKE_RIP_PI_lib_sn <- MLKE_RIP_PI1_counts_sn$lib +  MLKE_RIP_PI1_counts_sn$lib
MLKE_RIP_PI_d <- DGEList(counts=as.matrix(MLKE_RIP_PI_counts_sn), lib.size=MLKE_RIP_PI_lib_sn)
MLKE_RIP_PI_rpkm <- data.frame(rpkm(MLKE_RIP_PI_d,width(sn_tx)))
MLKE_RIP_PARP_d <- DGEList(counts=as.matrix(MLKE_RIP_PARP_counts_sn), lib.size=MLKE_RIP_PARP_lib_sn)
MLKE_RIP_PARP_rpkm <- data.frame(rpkm(MLKE_RIP_PARP_d,width(sn_tx)))
Venkat Malladi's avatar
Venkat Malladi committed
653
MLKE_RIP_PARP_rpkm_sn <- MLKE_RIP_PARP_rpkm
Venkat Malladi's avatar
Venkat Malladi committed
654 655 656 657

MLKE_RIP_FC <- data.frame((MLKE_RIP_PARP_rpkm+1)/(MLKE_RIP_PI_rpkm+1))
mlke_sn_rpkm_fc <- sn_tx[MLKE_RNA_sn_rpkm>=1 & MLKE_RIP_FC>=2 ]

658
mlke_sn_bound_transcripts <- NROW(unique(unlist(mcols(mlke_sn_rpkm_fc)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
659 660 661 662 663 664 665 666
sn_ratio <- NROW(unique(unlist(mcols(mlke_sn_rpkm_fc)$tx_name)))/NROW(unique(unlist(mcols(mlke_sn_rpkm)$tx_name)))

MLKE_RIP_sn <- data.frame(MLKE_RIP_PI_rpkm,MLKE_RIP_PARP_rpkm)
colnames(MLKE_RIP_sn) <- c('PI', 'PARP1')
MLKE_RIP_sn_rpkm <- MLKE_RIP_sn[MLKE_RNA_sn_rpkm>=1 & MLKE_RIP_FC>=2,]

mlke_allsno <- c(mlke_sno_rpkm_fc,mlke_sn_rpkm_fc)
mlke_allsno_rpkm <- rbind(MLKE_RIP_sno_rpkm,MLKE_RIP_sn_rpkm)
Venkat Malladi's avatar
Venkat Malladi committed
667 668
allsno_rna <- c(sno_tx,sn_tx)
mlke_allsno_rna_rpkm <- rbind(MLKE_RNA_sno_rpkm,MLKE_RNA_sn_rpkm)
Venkat Malladi's avatar
Venkat Malladi committed
669

670
# Bar plot
Venkat Malladi's avatar
Venkat Malladi committed
671
# Grouped Bar Plot
672
jpeg('figures/barchart-mcf-7-e2-species.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
673 674 675 676 677 678 679
ratios <- c(pc_ratio,lnc_ratio,sno_ratio,sn_ratio)
barplot(ratios, main="SNORNA MCF-7 E2", col=c("red","black", "dimgrey", "lightgrey"),ylim=c(0,.5))
dev.off()

boundTesting <-matrix(c(519,5882,170,260),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("mRNA", "snoRNA")))
fisher.test(boundTesting)

680 681
# Boxplot of Preimmune vs PARP-1
jpeg('figures/boxplot-mcf-7-e2-species.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
682 683 684
boxplot(MLKE_RIP_sno_rpkm,col=(c("orange","blue")),outline=FALSE,ylim = c(0,300),yaxt="n", cex.axis=1,las=2,lwd=4,lty=1)
axis(2, at=seq(0,300,100))
dev.off()
685

Venkat Malladi's avatar
Venkat Malladi committed
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
wilcox.test(MLKE_RIP_sno_rpkm[,1], MLKE_RIP_sno_rpkm[,2],paired=T)


# Get Categories of  snoRNA
mlke_gr_snotx <- data.frame(seqnames=seqnames(mlke_sno_rpkm),
  starts=start(mlke_sno_rpkm)-1,
  ends=end(mlke_sno_rpkm),
  strand=strand(mlke_sno_rpkm),
  tx_name = elementMetadata(mlke_sno_rpkm)$tx_name,
  gene_id = unlist(elementMetadata(mlke_sno_rpkm)$gene_id))

sno_annotations <- read.table('RNA_small_nucleolar.txt',header = TRUE, sep = "\t")
sno_inx <- match(matrix(unlist(strsplit(as.character(mlke_gr_snotx$gene_id),split='.',fixed=T)),ncol=2,byrow=T)[,1], sno_annotations$ensembl_gene_id)
mlke_gr_snotx$symbol <- as.character(sno_annotations[sno_inx,"symbol"])
mlke_gr_snotx$gene_family <- as.character(sno_annotations[sno_inx,"gene_family"])
mlke_gr_snotx$gene_family[mlke_gr_snotx$gene_family == "Small nucleolar RNAs, H/ACA box"] <- "H/ACA box"
mlke_gr_snotx$gene_family[mlke_gr_snotx$gene_family == "Small nucleolar RNAs, C/D box"] <- "C/D box"
mlke_gr_snotx$gene_family[mlke_gr_snotx$gene_family == "Small Cajal body-specific RNAs"] <- "scaRNA"
mlke_gr_snotx$gene_family[mlke_gr_snotx$gene_family == ""] <- "Other"
mlke_gr_snotx$gene_family[is.na(mlke_gr_snotx$gene_family)] <- "Other"

ha_rna <- dim(mlke_gr_snotx[mlke_gr_snotx$gene_family == "H/ACA box",])[1]
cd_rna <- dim(mlke_gr_snotx[mlke_gr_snotx$gene_family == "C/D box",])[1]
sc_rna <- dim(mlke_gr_snotx[mlke_gr_snotx$gene_family == "scaRNA",])[1]

dat = data.frame(count=c(ha_rna, cd_rna, sc_rna), category=c("H/ACA box", "C/D box", "scaRNA"))
dat$fraction = dat$count / sum(dat$count)

dat$ymax = cumsum(dat$fraction)
dat$ymin = c(0, head(dat$ymax, n=-1))

dat$category <- factor(dat$category, levels = c("H/ACA box", "C/D box", "scaRNA"))

719 720
# Piechart of SNORNA Species
jpeg('figures/piechart-mcf-7-e2-species.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751
ggplot(dat, aes(fill=category, ymax=ymax, ymin=ymin, xmax=4, xmin=2)) +
  geom_rect(fill=c('darkorchid1', "darkorange1","darkgreen")) +
   coord_polar(theta="y") +
   xlim(c(0, 4)) +
   theme_bw() +
   theme(panel.grid=element_blank()) +
   theme(axis.text=element_blank()) +
   theme(axis.ticks=element_blank())
dev.off()


mlke_gr_snotx <- data.frame(seqnames=seqnames(mlke_sno_rpkm_fc),
  starts=start(mlke_sno_rpkm_fc)-1,
  ends=end(mlke_sno_rpkm_fc),
  strand=strand(mlke_sno_rpkm_fc),
  tx_name = elementMetadata(mlke_sno_rpkm_fc)$tx_name,
  gene_id = unlist(elementMetadata(mlke_sno_rpkm_fc)$gene_id))

sno_inx <- match(matrix(unlist(strsplit(as.character(mlke_gr_snotx$gene_id),split='.',fixed=T)),ncol=2,byrow=T)[,1], sno_annotations$ensembl_gene_id)
mlke_gr_snotx$symbol <- as.character(sno_annotations[sno_inx,"symbol"])
mlke_gr_snotx$gene_family <- as.character(sno_annotations[sno_inx,"gene_family"])
mlke_gr_snotx$gene_family[mlke_gr_snotx$gene_family == "Small nucleolar RNAs, H/ACA box"] <- "H/ACA box"
mlke_gr_snotx$gene_family[mlke_gr_snotx$gene_family == "Small nucleolar RNAs, C/D box"] <- "C/D box"
mlke_gr_snotx$gene_family[mlke_gr_snotx$gene_family == "Small Cajal body-specific RNAs"] <- "scaRNA"
mlke_gr_snotx$gene_family[mlke_gr_snotx$gene_family == ""] <- "Other"
mlke_gr_snotx$gene_family[is.na(mlke_gr_snotx$gene_family)] <- "Other"

ha_rip <- dim(mlke_gr_snotx[mlke_gr_snotx$gene_family == "H/ACA box",])[1]
cd_rip <- dim(mlke_gr_snotx[mlke_gr_snotx$gene_family == "C/D box",])[1]
sc_rip<- dim(mlke_gr_snotx[mlke_gr_snotx$gene_family == "scaRNA",])[1]

752 753
# Bar plot of SnoRNA species
jpeg('figures/barchart-mcf-7-e2-species_snospecies.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769
ratios <- c(sn_ratio,ha_rip/ha_rna,cd_rip/cd_rna,sc_rip/sc_rna)
barplot(ratios, main="snoRNA species MCF-7 E2", col=c('pink1','darkorchid1', "darkorange1","darkgreen"),ylim=c(0,1))
dev.off()

typeTesting <-matrix(c(56,22,32,82),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("HA", "CD")))
fisher.test(typeTesting)

# Combine snRNA and snoRNA and print out
allsnotx_e2 <- data.frame(seqnames=seqnames(mlke_allsno),
  starts=start(mlke_allsno)-1,
  ends=end(mlke_allsno),
  strand=strand(mlke_allsno),
  tx_id = elementMetadata(mlke_allsno)$tx_name,
  gene_id = unlist(elementMetadata(mlke_allsno)$gene_id))

allsnotx_e2_rpkm <- cbind(allsnotx_e2,mlke_allsno_rpkm)
770 771
sno_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snoRNA_mapping.txt", header=F, sep=',')
sn_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snRNA_mapping.txt", header=F, sep=',')
Venkat Malladi's avatar
Venkat Malladi committed
772 773 774 775
gencode_sn_mapping <-rbind(sno_mapping,sn_mapping)
sn_inx <- match(allsnotx_e2_rpkm$tx_id, gencode_sn_mapping$V2)
allsnotx_e2_rpkm$tx_name <- as.character(gencode_sn_mapping[sn_inx,"V4"])
allsnotx_e2_rpkm$gene_name <- as.character(gencode_sn_mapping[sn_inx,"V3"])
776
write.table(allsnotx_e2_rpkm, file="tables/mcf-7-e2-snRNA_RPKM_1_FC_2.tsv", quote=F, sep="\t", row.names=F, col.names=T)
Venkat Malladi's avatar
Venkat Malladi committed
777 778 779 780 781 782 783 784 785

allsnotx_rna <- data.frame(seqnames=seqnames(allsno_rna),
  starts=start(allsno_rna)-1,
  ends=end(allsno_rna),
  strand=strand(allsno_rna),
  tx_id = elementMetadata(allsno_rna)$tx_name,
  gene_id = unlist(elementMetadata(allsno_rna)$gene_id))

mlke_allsnotx_rna_rpkm <- cbind(allsnotx_rna,mlke_allsno_rna_rpkm)
786 787
sno_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snoRNA_mapping.txt", header=F, sep=',')
sn_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snRNA_mapping.txt", header=F, sep=',')
Venkat Malladi's avatar
Venkat Malladi committed
788 789 790 791
gencode_sn_mapping <-rbind(sno_mapping,sn_mapping)
sn_inx <- match(mlke_allsnotx_rna_rpkm$tx_id, gencode_sn_mapping$V2)
mlke_allsnotx_rna_rpkm$tx_name <- as.character(gencode_sn_mapping[sn_inx,"V4"])
mlke_allsnotx_rna_rpkm$gene_name <- as.character(gencode_sn_mapping[sn_inx,"V3"])
792
write.table(mlke_allsnotx_rna_rpkm, file="tables/mcf-7-e2-snRNA_RPKM_RNA.tsv", quote=F, sep="\t", row.names=F, col.names=T)
Venkat Malladi's avatar
Venkat Malladi committed
793

Venkat Malladi's avatar
Venkat Malladi committed
794
```
795

Venkat Malladi's avatar
Venkat Malladi committed
796

797
# Overlap of snoRNA and snRNA MCF7 Basal and E2
798 799
``` {r snoRNA Overlap}

800
# Overlap
801 802 803
basal_unique <- unique(mlk_gr_snotx$tx_name)
e2_unique <- unique(mlke_gr_snotx$tx_name)
overlap <- calculate.overlap(x = list("Basal" = basal_unique,"E2" = e2_unique))
804
jpeg('figures/venndigram_basal_E2_snoRNA.jpg')
805 806
draw.pairwise.venn(area1 = length(overlap$a1), area2 = length(overlap$a2), cross.area = length(overlap$a3),col = c("royalblue4", "seagreen4"),lwd=4)
dev.off()
Venkat Malladi's avatar
Venkat Malladi committed
807

808
# RPKM boxplots
Venkat Malladi's avatar
Venkat Malladi committed
809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836
all_basal <- c(sno_tx,sn_tx)
allbasal_rpkm <- rbind(MLK_RIP_PARP_rpkm_sno,MLK_RIP_PARP_rpkm_sn)
alle2_rpkm <- rbind(MLKE_RIP_PARP_rpkm_sno,MLKE_RIP_PARP_rpkm_sn)
allbasal_rpkm_RNA <- rbind(MLK_RNA_sno_rpkm,MLK_RNA_sn_rpkm)
alle2_rpkm_RNA <- rbind(MLKE_RNA_sno_rpkm,MLKE_RNA_sn_rpkm)

all_basaltx <- data.frame(seqnames=seqnames(all_basal),
  starts=start(all_basal)-1,
  ends=end(all_basal),
  strand=strand(all_basal),
  tx_id = elementMetadata(all_basal)$tx_name,
  gene_id = unlist(elementMetadata(all_basal)$gene_id))

all_basaltx_rpkm <- cbind(all_basaltx,allbasal_rpkm)
all_e2tx_rpkm <- cbind(all_basaltx,alle2_rpkm)
all_basaltx_rpkm_RNA <- cbind(all_basaltx,allbasal_rpkm_RNA)
all_e2tx_rpkm_RNA <- cbind(all_basaltx,alle2_rpkm_RNA)

both_basal_e2 <- cbind(basal=all_basaltx_rpkm[all_basaltx_rpkm$tx_id %in% overlap$a3,]$Sample1,e2=all_e2tx_rpkm[all_e2tx_rpkm$tx_id %in% overlap$a3,]$Sample1)
both_basal_e2_RNA <- cbind(basal=all_basaltx_rpkm_RNA[all_basaltx_rpkm_RNA$tx_id %in% overlap$a3,]$Sample1,e2=all_e2tx_rpkm_RNA[all_e2tx_rpkm_RNA$tx_id %in% overlap$a3,]$Sample1)


only_e <- overlap$a2[!(overlap$a2 %in% overlap$a3)]
only_e2 <- cbind(basal=all_basaltx_rpkm[all_basaltx_rpkm$tx_id %in% only_e,]$Sample1,e2=allsnotx_e2_rpkm[allsnotx_e2_rpkm$tx_id %in% only_e,]$PARP1)

only_b <- overlap$a1[!(overlap$a1 %in% overlap$a3)]
only_basal <- cbind(basal=allsnotx_rpkm[allsnotx_rpkm$tx_id %in% only_b,]$PARP1,e2=all_e2tx_rpkm[all_e2tx_rpkm$tx_id %in% only_b,]$Sample1)

837
jpeg('figures/boxplot_common_mcf7_basal_e2.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
838 839 840
boxplot(both_basal_e2,col=(c("royalblue4","seagreen4")),outline=FALSE,ylim = c(0,500),yaxt="n", cex.axis=1,las=2,lwd=4,lty=1)
axis(2, at=seq(0,500,100))
dev.off()
841

Venkat Malladi's avatar
Venkat Malladi committed
842 843
wilcox.test(both_basal_e2[,1], both_basal_e2[,2],paired=T)

844
jpeg('figures/boxplot_common_mcf7_basal_e2_RNA.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
845 846 847
boxplot(both_basal_e2_RNA,col=(c("royalblue4","seagreen4")),outline=FALSE,ylim = c(0,125),yaxt="n", cex.axis=1,las=2,lwd=4,lty=1)
axis(2, at=seq(0,125,25))
dev.off()
848

Venkat Malladi's avatar
Venkat Malladi committed
849 850
wilcox.test(both_basal_e2_RNA[,1], both_basal_e2_RNA[,2],paired=T)

851
jpeg('figures/boxplot_mcf7_e2_only.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
852 853 854
boxplot(only_e2,col=(c("royalblue4","seagreen4")),outline=FALSE,ylim = c(0,80),yaxt="n", cex.axis=1,las=2,lwd=4,lty=1)
axis(2, at=seq(0,80,20))
dev.off()
855

Venkat Malladi's avatar
Venkat Malladi committed
856 857
wilcox.test(only_e2[,1], only_e2[,2],paired=T)

858
jpeg('figures/boxplot_mcf7_basal_only.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
859 860 861
boxplot(only_basal,col=(c("royalblue4","seagreen4")),outline=FALSE,ylim = c(0,250),yaxt="n", cex.axis=1,las=2,lwd=4,lty=1)
axis(2, at=seq(0,250,50))
dev.off()
862

Venkat Malladi's avatar
Venkat Malladi committed
863 864
wilcox.test(only_basal[,1], only_basal[,2],paired=T)

865
```
Venkat Malladi's avatar
Venkat Malladi committed
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921


```{r alignments ac16}
ALK_RNA1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RNAseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_ALK_RNA1/align-star-se.sh-1.0.0/ALK_RNA1_ACAGTG_L008_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
ALK_RNA2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RNAseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_ALK_RNA2/align-star-se.sh-1.0.0/ALK_RNA2_GATCAG_L008_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"

ALK_RIP_PI1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_ALK_RIP1_PI/align-star-se.sh-2.0.0/ALK_RIP1_PI_AGTCAA_L006_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
ALK_RIP_PI2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_ALK_RIP2_PI/align-star-se.sh-2.0.0/ALK_RIP2_PI_GTTTCG_L007_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"

ALK_RIP_PARP1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_ALK_RIP1_PARP1/align-star-se.sh-2.0.0/ALK_RIP1_PARP1_AGTTCC_L006_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
ALK_RIP_PARP2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_ALK_RIP2_PARP1/align-star-se.sh-2.0.0/ALK_RIP2_PARP1_CGTACG_L006_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
```

```{r counts ac16}
ALK_RNA1_counts_ref <- CountRefseq(ref_tx, ALK_RNA1, all_sn_tx, removeSNORNA=TRUE)
ALK_RNA2_counts_ref <- CountRefseq(ref_tx, ALK_RNA2, all_sn_tx, removeSNORNA=TRUE)

ALK_RNA1_counts_lnc <- CountRefseq(lnc_tx, ALK_RNA1, all_sn_tx, removeSNORNA=TRUE)
ALK_RNA2_counts_lnc <- CountRefseq(lnc_tx, ALK_RNA2, all_sn_tx, removeSNORNA=TRUE)

ALK_RNA1_counts_sn <- CountSNRNA(sn_tx, ALK_RNA1)
ALK_RNA2_counts_sn <- CountSNRNA(sn_tx, ALK_RNA2)

ALK_RNA1_counts_sno <- CountSNRNA(sno_tx, ALK_RNA1)
ALK_RNA2_counts_sno <- CountSNRNA(sno_tx, ALK_RNA2)


ALK_RIP_PI1_counts_ref <- CountRefseq(ref_tx, ALK_RIP_PI1, all_sn_tx, removeSNORNA=TRUE)
ALK_RIP_PI2_counts_ref <- CountRefseq(ref_tx, ALK_RIP_PI2, all_sn_tx, removeSNORNA=TRUE)

ALK_RIP_PI1_counts_lnc <- CountRefseq(lnc_tx, ALK_RIP_PI1, all_sn_tx, removeSNORNA=TRUE)
ALK_RIP_PI2_counts_lnc <- CountRefseq(lnc_tx, ALK_RIP_PI2, all_sn_tx, removeSNORNA=TRUE)

ALK_RIP_PI1_counts_sn <- CountSNRNA(sn_tx, ALK_RIP_PI1)
ALK_RIP_PI2_counts_sn <- CountSNRNA(sn_tx, ALK_RIP_PI2)

ALK_RIP_PI1_counts_sno <- CountSNRNA(sno_tx, ALK_RIP_PI1)
ALK_RIP_PI2_counts_sno <- CountSNRNA(sno_tx, ALK_RIP_PI2)

ALK_RIP_PARP1_counts_ref <- CountRefseq(ref_tx, ALK_RIP_PARP1, all_sn_tx, removeSNORNA=TRUE)
ALK_RIP_PARP2_counts_ref <- CountRefseq(ref_tx, ALK_RIP_PARP2, all_sn_tx, removeSNORNA=TRUE)

ALK_RIP_PARP1_counts_lnc <- CountRefseq(lnc_tx, ALK_RIP_PARP1, all_sn_tx, removeSNORNA=TRUE)
ALK_RIP_PARP2_counts_lnc <- CountRefseq(lnc_tx, ALK_RIP_PARP2, all_sn_tx, removeSNORNA=TRUE)

ALK_RIP_PARP1_counts_sn <- CountSNRNA(sn_tx, ALK_RIP_PARP1)
ALK_RIP_PARP2_counts_sn <- CountSNRNA(sn_tx, ALK_RIP_PARP2)

ALK_RIP_PARP1_counts_sno <- CountSNRNA(sno_tx, ALK_RIP_PARP1)
ALK_RIP_PARP2_counts_sno <- CountSNRNA(sno_tx, ALK_RIP_PARP2)


```

# RPKM Cutoff
``` {r rpkm ac16}
922
# Refseq Genes
Venkat Malladi's avatar
Venkat Malladi committed
923 924 925 926 927
ALK_RNA_counts_ref <- ALK_RNA1_counts_ref$counts +  ALK_RNA2_counts_ref$counts
ALK_RNA_lib_ref <- ALK_RNA1_counts_ref$lib +  ALK_RNA2_counts_ref$lib
ALK_RNA_ref_d <- DGEList(counts=as.matrix(ALK_RNA_counts_ref), lib.size=ALK_RNA_lib_ref)
ALK_RNA_ref_rpkm <- data.frame(rpkm(ALK_RNA_ref_d,width(ref_tx)))
alk_pc_rpkm <- ref_tx[ALK_RNA_ref_rpkm>=1]
928 929 930

alk_pc_expressed_transcripts <- NROW(unique(unlist(mcols(alk_pc_rpkm)$tx_name)))
alk_pc_expressed_genes <- NROW(unique(unlist(mcols(alk_pc_rpkm)$gene_name)))
Venkat Malladi's avatar
Venkat Malladi committed
931 932 933 934 935 936 937 938 939 940 941 942

ALK_RIP_PARP_counts_ref <- ALK_RIP_PARP1_counts_ref$counts +  ALK_RIP_PARP2_counts_ref$counts
ALK_RIP_PARP_lib_ref <- ALK_RIP_PARP1_counts_ref$lib +  ALK_RIP_PARP2_counts_ref$lib
ALK_RIP_PI_counts_ref <- ALK_RIP_PI1_counts_ref$counts +  ALK_RIP_PI2_counts_ref$counts
ALK_RIP_PI_lib_ref <- ALK_RIP_PI1_counts_ref$lib +  ALK_RIP_PI1_counts_ref$lib
ALK_RIP_PI_d <- DGEList(counts=as.matrix(ALK_RIP_PI_counts_ref), lib.size=ALK_RIP_PI_lib_ref)
ALK_RIP_PI_rpkm <- data.frame(rpkm(ALK_RIP_PI_d,width(ref_tx)))
ALK_RIP_PARP_d <- DGEList(counts=as.matrix(ALK_RIP_PARP_counts_ref), lib.size=ALK_RIP_PARP_lib_ref)
ALK_RIP_PARP_rpkm <- data.frame(rpkm(ALK_RIP_PARP_d,width(ref_tx)))

ALK_RIP_FC <- data.frame((ALK_RIP_PARP_rpkm+1)/(ALK_RIP_PI_rpkm+1))
alk_pc_rpkm_fc <- ref_tx[ALK_RNA_ref_rpkm>=1 & ALK_RIP_FC>=2 ]
943 944 945

alk_pc_bound_transcripts <- NROW(unique(unlist(mcols(alk_pc_rpkm_fc)$tx_name)))
alk_pc_bound_genes <- NROW(unique(unlist(mcols(alk_pc_rpkm_fc)$gene_name)))
Venkat Malladi's avatar
Venkat Malladi committed
946 947
pc_ratio <- NROW(unique(unlist(mcols(alk_pc_rpkm_fc)$gene_name)))/NROW(unique(unlist(mcols(alk_pc_rpkm)$gene_name)))

948
# LncRNA Genes
Venkat Malladi's avatar
Venkat Malladi committed
949 950 951 952 953
ALK_RNA_counts_lnc <- ALK_RNA1_counts_lnc$counts +  ALK_RNA2_counts_lnc$counts
ALK_RNA_lib_lnc <- ALK_RNA1_counts_lnc$lib +  ALK_RNA2_counts_lnc$lib
ALK_RNA_lnc_d <- DGEList(counts=as.matrix(ALK_RNA_counts_lnc), lib.size=ALK_RNA_lib_lnc)
ALK_RNA_lnc_rpkm <- data.frame(rpkm(ALK_RNA_lnc_d,width(lnc_tx)))
alk_lnc_rpkm <- lnc_tx[ALK_RNA_lnc_rpkm>=1]
954 955 956

alk_lnc_expressed_transcripts <- NROW(unique(unlist(mcols(alk_lnc_rpkm)$tx_name)))
alk_lnc_expressed_genes <- NROW(unique(unlist(mcols(alk_lnc_rpkm)$gene_id)))
Venkat Malladi's avatar
Venkat Malladi committed
957 958 959 960 961 962 963 964 965 966 967 968 969

ALK_RIP_PARP_counts_lnc <- ALK_RIP_PARP1_counts_lnc$counts +  ALK_RIP_PARP2_counts_lnc$counts
ALK_RIP_PARP_lib_lnc<- ALK_RIP_PARP1_counts_lnc$lib +  ALK_RIP_PARP2_counts_lnc$lib
ALK_RIP_PI_counts_lnc <- ALK_RIP_PI1_counts_lnc$counts +  ALK_RIP_PI2_counts_lnc$counts
ALK_RIP_PI_lib_lnc <- ALK_RIP_PI1_counts_lnc$lib +  ALK_RIP_PI1_counts_lnc$lib
ALK_RIP_PI_d <- DGEList(counts=as.matrix(ALK_RIP_PI_counts_lnc), lib.size=ALK_RIP_PI_lib_lnc)
ALK_RIP_PI_rpkm <- data.frame(rpkm(ALK_RIP_PI_d,width(lnc_tx)))
ALK_RIP_PARP_d <- DGEList(counts=as.matrix(ALK_RIP_PARP_counts_lnc), lib.size=ALK_RIP_PARP_lib_lnc)
ALK_RIP_PARP_rpkm <- data.frame(rpkm(ALK_RIP_PARP_d,width(lnc_tx)))

ALK_RIP_FC <- data.frame((ALK_RIP_PARP_rpkm+1)/(ALK_RIP_PI_rpkm+1))
alk_lnc_rpkm_fc <- lnc_tx[ALK_RNA_lnc_rpkm>=1 & ALK_RIP_FC>=2 ]

970 971 972
alk_lnc_bound_transcripts <- NROW(unique(unlist(mcols(alk_lnc_rpkm_fc)$tx_name)))
alk_lnc_bound_genes <- NROW(unique(unlist(mcols(alk_lnc_rpkm_fc)$gene_id)))
lnc_ratio <- NROW(unique(unlist(mcols(alk_lnc_rpkm_fc)$gene_id)))/NROW(unique(unlist(mcols(alk_lnc_rpkm)$gene_id)))
Venkat Malladi's avatar
Venkat Malladi committed
973

974
# SNORNA Genes
Venkat Malladi's avatar
Venkat Malladi committed
975 976 977 978 979
ALK_RNA_counts_sno <- ALK_RNA1_counts_sno$counts +  ALK_RNA2_counts_sno$counts
ALK_RNA_lib_sno <- ALK_RNA1_counts_sno$lib +  ALK_RNA1_counts_sno$lib
ALK_RNA_sno_d <- DGEList(counts=as.matrix(ALK_RNA_counts_sno), lib.size=ALK_RNA_lib_sno)
ALK_RNA_sno_rpkm <- data.frame(rpkm(ALK_RNA_sno_d,width(sno_tx)))
alk_sno_rpkm <- sno_tx[ALK_RNA_sno_rpkm>=1]
980 981

alk_sno_expressed_transcripts <- NROW(unique(unlist(mcols(alk_sno_rpkm)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
982 983 984 985 986 987 988 989 990 991 992 993 994

ALK_RIP_PARP_counts_sno <- ALK_RIP_PARP1_counts_sno$counts +  ALK_RIP_PARP2_counts_sno$counts
ALK_RIP_PARP_lib_sno<- ALK_RIP_PARP1_counts_sno$lib +  ALK_RIP_PARP2_counts_sno$lib
ALK_RIP_PI_counts_sno <- ALK_RIP_PI1_counts_sno$counts +  ALK_RIP_PI2_counts_sno$counts
ALK_RIP_PI_lib_sno <- ALK_RIP_PI1_counts_sno$lib +  ALK_RIP_PI1_counts_sno$lib
ALK_RIP_PI_d <- DGEList(counts=as.matrix(ALK_RIP_PI_counts_sno), lib.size=ALK_RIP_PI_lib_sno)
ALK_RIP_PI_rpkm <- data.frame(rpkm(ALK_RIP_PI_d,width(sno_tx)))
ALK_RIP_PARP_d <- DGEList(counts=as.matrix(ALK_RIP_PARP_counts_sno), lib.size=ALK_RIP_PARP_lib_sno)
ALK_RIP_PARP_rpkm <- data.frame(rpkm(ALK_RIP_PARP_d,width(sno_tx)))


ALK_RIP_FC <- data.frame((ALK_RIP_PARP_rpkm+1)/(ALK_RIP_PI_rpkm+1))
alk_sno_rpkm_fc <- sno_tx[ALK_RNA_sno_rpkm>=1 & ALK_RIP_FC>=2 ]
995 996

alk_sno_bound_transcripts <-NROW(unique(unlist(mcols(alk_sno_rpkm_fc)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
997 998 999 1000 1001 1002
sno_ratio <- NROW(unique(unlist(mcols(alk_sno_rpkm_fc)$tx_name)))/NROW(unique(unlist(mcols(alk_sno_rpkm)$tx_name)))

ALK_RIP_sno <- data.frame(ALK_RIP_PI_rpkm,ALK_RIP_PARP_rpkm)
colnames(ALK_RIP_sno) <- c('PI', 'PARP1')
ALK_RIP_sno_rpkm <- ALK_RIP_sno[ALK_RNA_sno_rpkm>=1 & ALK_RIP_FC>=2,]

1003
# SNRNA Genes
Venkat Malladi's avatar
Venkat Malladi committed
1004 1005 1006 1007 1008
ALK_RNA_counts_sn <- ALK_RNA1_counts_sn$counts +  ALK_RNA2_counts_sn$counts
ALK_RNA_lib_sn <- ALK_RNA1_counts_sn$lib +  ALK_RNA1_counts_sn$lib
ALK_RNA_sn_d <- DGEList(counts=as.matrix(ALK_RNA_counts_sn), lib.size=ALK_RNA_lib_sn)
ALK_RNA_sn_rpkm <- data.frame(rpkm(ALK_RNA_sn_d,width(sn_tx)))
alk_sn_rpkm <- sn_tx[ALK_RNA_sn_rpkm>=1]
1009 1010

alk_sn_expressed_transcripts <- NROW(unique(unlist(mcols(alk_sn_rpkm)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023

ALK_RIP_PARP_counts_sn <- ALK_RIP_PARP1_counts_sn$counts +  ALK_RIP_PARP2_counts_sn$counts
ALK_RIP_PARP_lib_sn<- ALK_RIP_PARP1_counts_sn$lib +  ALK_RIP_PARP2_counts_sn$lib
ALK_RIP_PI_counts_sn <- ALK_RIP_PI1_counts_sn$counts +  ALK_RIP_PI2_counts_sn$counts
ALK_RIP_PI_lib_sn <- ALK_RIP_PI1_counts_sn$lib +  ALK_RIP_PI1_counts_sn$lib
ALK_RIP_PI_d <- DGEList(counts=as.matrix(ALK_RIP_PI_counts_sn), lib.size=ALK_RIP_PI_lib_sn)
ALK_RIP_PI_rpkm <- data.frame(rpkm(ALK_RIP_PI_d,width(sn_tx)))
ALK_RIP_PARP_d <- DGEList(counts=as.matrix(ALK_RIP_PARP_counts_sn), lib.size=ALK_RIP_PARP_lib_sn)
ALK_RIP_PARP_rpkm <- data.frame(rpkm(ALK_RIP_PARP_d,width(sn_tx)))

ALK_RIP_FC <- data.frame((ALK_RIP_PARP_rpkm+1)/(ALK_RIP_PI_rpkm+1))
alk_sn_rpkm_fc <- sn_tx[ALK_RNA_sn_rpkm>=1 & ALK_RIP_FC>=2 ]

1024
alk_sn_bound_transcripts <- NROW(unique(unlist(mcols(alk_sn_rpkm_fc)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035
sn_ratio <- NROW(unique(unlist(mcols(alk_sn_rpkm_fc)$tx_name)))/NROW(unique(unlist(mcols(alk_sn_rpkm)$tx_name)))

ALK_RIP_sn <- data.frame(ALK_RIP_PI_rpkm,ALK_RIP_PARP_rpkm)
colnames(ALK_RIP_sn) <- c('PI', 'PARP1')
ALK_RIP_sn_rpkm <- ALK_RIP_sn[ALK_RNA_sn_rpkm>=1 & ALK_RIP_FC>=2,]

alk_allsno <- c(alk_sno_rpkm_fc,alk_sn_rpkm_fc)
alk_allsno_rpkm <- rbind(ALK_RIP_sno_rpkm,ALK_RIP_sn_rpkm)
allsno_rna <- c(sno_tx,sn_tx)
alk_allsno_rna_rpkm <- rbind(ALK_RNA_sno_rpkm,ALK_RNA_sn_rpkm)

1036
# bar plot (Figure Supp. 2B)
Venkat Malladi's avatar
Venkat Malladi committed
1037
# Grouped Bar Plot
1038
jpeg('figures/barchart-ac16-species.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
1039 1040 1041 1042
ratios <- c(pc_ratio,lnc_ratio,sno_ratio,sn_ratio)
barplot(ratios, main="SNORNA AC16", col=c("red","black", "dimgrey", "lightgrey"),ylim=c(0,.5))
dev.off()

1043 1044 1045 1046 1047 1048 1049
boundTesting <-matrix(c(68,6619,184,319),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("mRNA", "snoRNA")))
fisher.test(boundTesting)

boundTesting <-matrix(c(1159,8796,184,319),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("lncRNA", "snoRNA")))
fisher.test(boundTesting)

boundTesting <-matrix(c(76,239,184,319),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("mRNA", "snoRNA")))
Venkat Malladi's avatar
Venkat Malladi committed
1050 1051
fisher.test(boundTesting)

1052 1053
# Boxplot of Preimmune vs PARP-1 (Figure Supp. 2C)
jpeg('figures/boxplot-ac16-species.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
1054 1055 1056
boxplot(ALK_RIP_sno_rpkm,col=(c("orange","blue")),outline=FALSE,ylim = c(0,200),yaxt="n", cex.axis=1,las=2,lwd=4,lty=1)
axis(2, at=seq(0,200,50))
dev.off()
1057

Venkat Malladi's avatar
Venkat Malladi committed
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068
wilcox.test(ALK_RIP_sno_rpkm[,1], ALK_RIP_sno_rpkm[,2],paired=T)


# Get Categories of  snoRNA
alk_gr_snotx <- data.frame(seqnames=seqnames(alk_sno_rpkm),
  starts=start(alk_sno_rpkm)-1,
  ends=end(alk_sno_rpkm),
  strand=strand(alk_sno_rpkm),
  tx_name = elementMetadata(alk_sno_rpkm)$tx_name,
  gene_id = unlist(elementMetadata(alk_sno_rpkm)$gene_id))

1069
sno_annotations <- read.table('reference_annotations/RNA_small_nucleolar.txt',header = TRUE, sep = "\t")
Venkat Malladi's avatar
Venkat Malladi committed
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090
sno_inx <- match(matrix(unlist(strsplit(as.character(alk_gr_snotx$gene_id),split='.',fixed=T)),ncol=2,byrow=T)[,1], sno_annotations$ensembl_gene_id)
alk_gr_snotx$symbol <- as.character(sno_annotations[sno_inx,"symbol"])
alk_gr_snotx$gene_family <- as.character(sno_annotations[sno_inx,"gene_family"])
alk_gr_snotx$gene_family[alk_gr_snotx$gene_family == "Small nucleolar RNAs, H/ACA box"] <- "H/ACA box"
alk_gr_snotx$gene_family[alk_gr_snotx$gene_family == "Small nucleolar RNAs, C/D box"] <- "C/D box"
alk_gr_snotx$gene_family[alk_gr_snotx$gene_family == "Small Cajal body-specific RNAs"] <- "scaRNA"
alk_gr_snotx$gene_family[alk_gr_snotx$gene_family == ""] <- "Other"
alk_gr_snotx$gene_family[is.na(alk_gr_snotx$gene_family)] <- "Other"

ha_rna <- dim(alk_gr_snotx[alk_gr_snotx$gene_family == "H/ACA box",])[1]
cd_rna <- dim(alk_gr_snotx[alk_gr_snotx$gene_family == "C/D box",])[1]
sc_rna <- dim(alk_gr_snotx[alk_gr_snotx$gene_family == "scaRNA",])[1]

dat = data.frame(count=c(ha_rna, cd_rna, sc_rna), category=c("H/ACA box", "C/D box", "scaRNA"))
dat$fraction = dat$count / sum(dat$count)

dat$ymax = cumsum(dat$fraction)
dat$ymin = c(0, head(dat$ymax, n=-1))

dat$category <- factor(dat$category, levels = c("H/ACA box", "C/D box", "scaRNA"))

1091 1092
# Piechart of SNORNA Species (Figure Supp. 2D)
jpeg('figures/piechart-ac16-species.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123
ggplot(dat, aes(fill=category, ymax=ymax, ymin=ymin, xmax=4, xmin=2)) +
  geom_rect(fill=c('darkorchid1', "darkorange1","darkgreen")) +
   coord_polar(theta="y") +
   xlim(c(0, 4)) +
   theme_bw() +
   theme(panel.grid=element_blank()) +
   theme(axis.text=element_blank()) +
   theme(axis.ticks=element_blank())
dev.off()


alk_gr_snotx <- data.frame(seqnames=seqnames(alk_sno_rpkm_fc),
  starts=start(alk_sno_rpkm_fc)-1,
  ends=end(alk_sno_rpkm_fc),
  strand=strand(alk_sno_rpkm_fc),
  tx_name = elementMetadata(alk_sno_rpkm_fc)$tx_name,
  gene_id = unlist(elementMetadata(alk_sno_rpkm_fc)$gene_id))

sno_inx <- match(matrix(unlist(strsplit(as.character(alk_gr_snotx$gene_id),split='.',fixed=T)),ncol=2,byrow=T)[,1], sno_annotations$ensembl_gene_id)
alk_gr_snotx$symbol <- as.character(sno_annotations[sno_inx,"symbol"])
alk_gr_snotx$gene_family <- as.character(sno_annotations[sno_inx,"gene_family"])
alk_gr_snotx$gene_family[alk_gr_snotx$gene_family == "Small nucleolar RNAs, H/ACA box"] <- "H/ACA box"
alk_gr_snotx$gene_family[alk_gr_snotx$gene_family == "Small nucleolar RNAs, C/D box"] <- "C/D box"
alk_gr_snotx$gene_family[alk_gr_snotx$gene_family == "Small Cajal body-specific RNAs"] <- "scaRNA"
alk_gr_snotx$gene_family[alk_gr_snotx$gene_family == ""] <- "Other"
alk_gr_snotx$gene_family[is.na(alk_gr_snotx$gene_family)] <- "Other"

ha_rip <- dim(alk_gr_snotx[alk_gr_snotx$gene_family == "H/ACA box",])[1]
cd_rip <- dim(alk_gr_snotx[alk_gr_snotx$gene_family == "C/D box",])[1]
sc_rip<- dim(alk_gr_snotx[alk_gr_snotx$gene_family == "scaRNA",])[1]

1124
# bar plot figure (Figure Supp. 2E)
Venkat Malladi's avatar
Venkat Malladi committed
1125
# Bar plot
1126
jpeg('figures/barchart-ac16-species_snospecies.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
1127 1128 1129 1130 1131 1132 1133
ratios <- c(sn_ratio,ha_rip/ha_rna,cd_rip/cd_rna,sc_rip/sc_rna)
barplot(ratios, main="snoRNA species AC 16", col=c('pink1','darkorchid1', "darkorange1","darkgreen"),ylim=c(0,1))
dev.off()

typeTesting <-matrix(c(50,28,49,115),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("HA", "CD")))
fisher.test(typeTesting)

1134 1135 1136 1137 1138 1139
typeTesting <-matrix(c(50,28,76,239),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("HA", "snRNA")))
fisher.test(typeTesting)

typeTesting <-matrix(c(50,28,7,13),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("HA", "scRNA")))
fisher.test(typeTesting)

Venkat Malladi's avatar
Venkat Malladi committed
1140 1141 1142 1143 1144 1145 1146 1147 1148
# Combine snRNA and snoRNA and print out
allsnotx_a <- data.frame(seqnames=seqnames(alk_allsno),
  starts=start(alk_allsno)-1,
  ends=end(alk_allsno),
  strand=strand(alk_allsno),
  tx_id = elementMetadata(alk_allsno)$tx_name,
  gene_id = unlist(elementMetadata(alk_allsno)$gene_id))

allsnotx_a_rpkm <- cbind(allsnotx_a,alk_allsno_rpkm)
1149 1150
sno_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snoRNA_mapping.txt", header=F, sep=',')
sn_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snRNA_mapping.txt", header=F, sep=',')
Venkat Malladi's avatar
Venkat Malladi committed
1151 1152 1153 1154
gencode_sn_mapping <-rbind(sno_mapping,sn_mapping)
sn_inx <- match(allsnotx_a_rpkm$tx_id, gencode_sn_mapping$V2)
allsnotx_a_rpkm$tx_name <- as.character(gencode_sn_mapping[sn_inx,"V4"])
allsnotx_a_rpkm$gene_name <- as.character(gencode_sn_mapping[sn_inx,"V3"])
1155
write.table(allsnotx_a_rpkm, file="tables/ac16-snRNA_RPKM_1_FC_2.tsv", quote=F, sep="\t", row.names=F, col.names=T)
Venkat Malladi's avatar
Venkat Malladi committed
1156 1157 1158 1159 1160 1161 1162 1163 1164

allsnotx_rna <- data.frame(seqnames=seqnames(allsno_rna),
  starts=start(allsno_rna)-1,
  ends=end(allsno_rna),
  strand=strand(allsno_rna),
  tx_id = elementMetadata(allsno_rna)$tx_name,
  gene_id = unlist(elementMetadata(allsno_rna)$gene_id))

alk_allsnotx_rna_rpkm <- cbind(allsnotx_rna,alk_allsno_rna_rpkm)
1165 1166
sno_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snoRNA_mapping.txt", header=F, sep=',')
sn_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snRNA_mapping.txt", header=F, sep=',')
Venkat Malladi's avatar
Venkat Malladi committed
1167 1168 1169 1170
gencode_sn_mapping <-rbind(sno_mapping,sn_mapping)
sn_inx <- match(alk_allsnotx_rna_rpkm$tx_id, gencode_sn_mapping$V2)
alk_allsnotx_rna_rpkm$tx_name <- as.character(gencode_sn_mapping[sn_inx,"V4"])
alk_allsnotx_rna_rpkm$gene_name <- as.character(gencode_sn_mapping[sn_inx,"V3"])
1171
write.table(alk_allsnotx_rna_rpkm, file="tables/ac16-snRNA_RPKM_RNA.tsv", quote=F, sep="\t", row.names=F, col.names=T)
Venkat Malladi's avatar
Venkat Malladi committed
1172 1173

```
Venkat Malladi's avatar
Venkat Malladi committed
1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228

```{r alignments TNF}
ALKT_RNA1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RNAseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_ALKT_RNA1/align-star-se.sh-1.0.0/ALKT_RNA1_GCCAAT_L007_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
ALKT_RNA2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RNAseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_ALKT_RNA2/align-star-se.sh-1.0.0/ALKT_RNA2_TAGCTT_L007_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"

ALKT_RIP_PI1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_ALKT_RIP1_PI/align-star-se.sh-2.0.0/ALKT_RIP1_PI_ATGTCA_L003_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
ALKT_RIP_PI2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_ALKT_RIP2_PI/align-star-se.sh-2.0.0/ALKT_RIP2_PI_GAGTGG_L003_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"

ALKT_RIP_PARP1 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_ALKT_RIP1_PARP1/align-star-se.sh-2.0.0/ALKT_RIP1_PARP1_CCGTCC_L006_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
ALKT_RIP_PARP2 <- "/Volumes/project/GCRB/Lee_Lab/s163035/DK_RIP-seq/PARP1_RIPseq_in_AC16_MCF7_withTNFa_E2/raw/Sample_ALKT_RIP2_PARP1/align-star-se.sh-2.0.0/ALKT_RIP2_PARP1_GGTAGC_L006_R1.rDNA.filtered.fastq.gz_filtered_chrMAligned.sortedByCoord.out.bam"
```

```{r counts TNF}
ALKT_RNA1_counts_ref <- CountRefseq(ref_tx, ALKT_RNA1, all_sn_tx, removeSNORNA=TRUE)
ALKT_RNA2_counts_ref <- CountRefseq(ref_tx, ALKT_RNA2, all_sn_tx, removeSNORNA=TRUE)

ALKT_RNA1_counts_lnc <- CountRefseq(lnc_tx, ALKT_RNA1, all_sn_tx, removeSNORNA=TRUE)
ALKT_RNA2_counts_lnc <- CountRefseq(lnc_tx, ALKT_RNA2, all_sn_tx, removeSNORNA=TRUE)

ALKT_RNA1_counts_sn <- CountSNRNA(sn_tx, ALKT_RNA1)
ALKT_RNA2_counts_sn <- CountSNRNA(sn_tx, ALKT_RNA2)

ALKT_RNA1_counts_sno <- CountSNRNA(sno_tx, ALKT_RNA1)
ALKT_RNA2_counts_sno <- CountSNRNA(sno_tx, ALKT_RNA2)


ALKT_RIP_PI1_counts_ref <- CountRefseq(ref_tx, ALKT_RIP_PI1, all_sn_tx, removeSNORNA=TRUE)
ALKT_RIP_PI2_counts_ref <- CountRefseq(ref_tx, ALKT_RIP_PI2, all_sn_tx, removeSNORNA=TRUE)

ALKT_RIP_PI1_counts_lnc <- CountRefseq(lnc_tx, ALKT_RIP_PI1, all_sn_tx, removeSNORNA=TRUE)
ALKT_RIP_PI2_counts_lnc <- CountRefseq(lnc_tx, ALKT_RIP_PI2, all_sn_tx, removeSNORNA=TRUE)

ALKT_RIP_PI1_counts_sn <- CountSNRNA(sn_tx, ALKT_RIP_PI1)
ALKT_RIP_PI2_counts_sn <- CountSNRNA(sn_tx, ALKT_RIP_PI2)

ALKT_RIP_PI1_counts_sno <- CountSNRNA(sno_tx, ALKT_RIP_PI1)
ALKT_RIP_PI2_counts_sno <- CountSNRNA(sno_tx, ALKT_RIP_PI2)

ALKT_RIP_PARP1_counts_ref <- CountRefseq(ref_tx, ALKT_RIP_PARP1, all_sn_tx, removeSNORNA=TRUE)
ALKT_RIP_PARP2_counts_ref <- CountRefseq(ref_tx, ALKT_RIP_PARP2, all_sn_tx, removeSNORNA=TRUE)

ALKT_RIP_PARP1_counts_lnc <- CountRefseq(lnc_tx, ALKT_RIP_PARP1, all_sn_tx, removeSNORNA=TRUE)
ALKT_RIP_PARP2_counts_lnc <- CountRefseq(lnc_tx, ALKT_RIP_PARP2, all_sn_tx, removeSNORNA=TRUE)

ALKT_RIP_PARP1_counts_sn <- CountSNRNA(sn_tx, ALKT_RIP_PARP1)
ALKT_RIP_PARP2_counts_sn <- CountSNRNA(sn_tx, ALKT_RIP_PARP2)

ALKT_RIP_PARP1_counts_sno <- CountSNRNA(sno_tx, ALKT_RIP_PARP1)
ALKT_RIP_PARP2_counts_sno <- CountSNRNA(sno_tx, ALKT_RIP_PARP2)


```

# RPKM Cutoff
``` {r rpkm TNF}
1229
# Refseq Genes
Venkat Malladi's avatar
Venkat Malladi committed
1230 1231 1232 1233 1234
ALKT_RNA_counts_ref <- ALKT_RNA1_counts_ref$counts +  ALKT_RNA2_counts_ref$counts
ALKT_RNA_lib_ref <- ALKT_RNA1_counts_ref$lib +  ALKT_RNA2_counts_ref$lib
ALKT_RNA_ref_d <- DGEList(counts=as.matrix(ALKT_RNA_counts_ref), lib.size=ALKT_RNA_lib_ref)
ALKT_RNA_ref_rpkm <- data.frame(rpkm(ALKT_RNA_ref_d,width(ref_tx)))
alkt_pc_rpkm <- ref_tx[ALKT_RNA_ref_rpkm>=1]
1235 1236 1237

alkt_pc_expressed_transcripts <- NROW(unique(unlist(mcols(alkt_pc_rpkm)$tx_name)))
alkt_pc_expressed_genes <- NROW(unique(unlist(mcols(alkt_pc_rpkm)$gene_name)))
Venkat Malladi's avatar
Venkat Malladi committed
1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249

ALKT_RIP_PARP_counts_ref <- ALKT_RIP_PARP1_counts_ref$counts +  ALKT_RIP_PARP2_counts_ref$counts
ALKT_RIP_PARP_lib_ref <- ALKT_RIP_PARP1_counts_ref$lib +  ALKT_RIP_PARP2_counts_ref$lib
ALKT_RIP_PI_counts_ref <- ALKT_RIP_PI1_counts_ref$counts +  ALKT_RIP_PI2_counts_ref$counts
ALKT_RIP_PI_lib_ref <- ALKT_RIP_PI1_counts_ref$lib +  ALKT_RIP_PI1_counts_ref$lib
ALKT_RIP_PI_d <- DGEList(counts=as.matrix(ALKT_RIP_PI_counts_ref), lib.size=ALKT_RIP_PI_lib_ref)
ALKT_RIP_PI_rpkm <- data.frame(rpkm(ALKT_RIP_PI_d,width(ref_tx)))
ALKT_RIP_PARP_d <- DGEList(counts=as.matrix(ALKT_RIP_PARP_counts_ref), lib.size=ALKT_RIP_PARP_lib_ref)
ALKT_RIP_PARP_rpkm <- data.frame(rpkm(ALKT_RIP_PARP_d,width(ref_tx)))

ALKT_RIP_FC <- data.frame((ALKT_RIP_PARP_rpkm+1)/(ALKT_RIP_PI_rpkm+1))
alkt_pc_rpkm_fc <- ref_tx[ALKT_RNA_ref_rpkm>=1 & ALKT_RIP_FC>=2 ]
1250 1251 1252

alkt_pc_bound_transcripts <- NROW(unique(unlist(mcols(alkt_pc_rpkm_fc)$tx_name)))
alkt_pc_bound_genes <- NROW(unique(unlist(mcols(alkt_pc_rpkm_fc)$gene_name)))
Venkat Malladi's avatar
Venkat Malladi committed
1253 1254
pc_ratio <- NROW(unique(unlist(mcols(alkt_pc_rpkm_fc)$gene_name)))/NROW(unique(unlist(mcols(alkt_pc_rpkm)$gene_name)))

1255
# LncRNA Genes
Venkat Malladi's avatar
Venkat Malladi committed
1256 1257 1258 1259 1260
ALKT_RNA_counts_lnc <- ALKT_RNA1_counts_lnc$counts +  ALKT_RNA2_counts_lnc$counts
ALKT_RNA_lib_lnc <- ALKT_RNA1_counts_lnc$lib +  ALKT_RNA2_counts_lnc$lib
ALKT_RNA_lnc_d <- DGEList(counts=as.matrix(ALKT_RNA_counts_lnc), lib.size=ALKT_RNA_lib_lnc)
ALKT_RNA_lnc_rpkm <- data.frame(rpkm(ALKT_RNA_lnc_d,width(lnc_tx)))
alkt_lnc_rpkm <- lnc_tx[ALKT_RNA_lnc_rpkm>=1]
1261 1262 1263

alkt_lnc_expressed_transcripts <- NROW(unique(unlist(mcols(alkt_lnc_rpkm)$tx_name)))
alkt_lnc_expressed_genes <- NROW(unique(unlist(mcols(alkt_lnc_rpkm)$gene_id)))
Venkat Malladi's avatar
Venkat Malladi committed
1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276

ALKT_RIP_PARP_counts_lnc <- ALKT_RIP_PARP1_counts_lnc$counts +  ALKT_RIP_PARP2_counts_lnc$counts
ALKT_RIP_PARP_lib_lnc<- ALKT_RIP_PARP1_counts_lnc$lib +  ALKT_RIP_PARP2_counts_lnc$lib
ALKT_RIP_PI_counts_lnc <- ALKT_RIP_PI1_counts_lnc$counts +  ALKT_RIP_PI2_counts_lnc$counts
ALKT_RIP_PI_lib_lnc <- ALKT_RIP_PI1_counts_lnc$lib +  ALKT_RIP_PI1_counts_lnc$lib
ALKT_RIP_PI_d <- DGEList(counts=as.matrix(ALKT_RIP_PI_counts_lnc), lib.size=ALKT_RIP_PI_lib_lnc)
ALKT_RIP_PI_rpkm <- data.frame(rpkm(ALKT_RIP_PI_d,width(lnc_tx)))
ALKT_RIP_PARP_d <- DGEList(counts=as.matrix(ALKT_RIP_PARP_counts_lnc), lib.size=ALKT_RIP_PARP_lib_lnc)
ALKT_RIP_PARP_rpkm <- data.frame(rpkm(ALKT_RIP_PARP_d,width(lnc_tx)))

ALKT_RIP_FC <- data.frame((ALKT_RIP_PARP_rpkm+1)/(ALKT_RIP_PI_rpkm+1))
alkt_lnc_rpkm_fc <- lnc_tx[ALKT_RNA_lnc_rpkm>=1 & ALKT_RIP_FC>=2 ]

1277 1278 1279
alkt_lnc_bound_transcripts <- NROW(unique(unlist(mcols(alkt_lnc_rpkm_fc)$tx_name)))
alkt_lnc_bound_genes <- NROW(unique(unlist(mcols(alkt_lnc_rpkm_fc)$gene_id)))
lnc_ratio <- NROW(unique(unlist(mcols(alkt_lnc_rpkm_fc)$gene_id)))/NROW(unique(unlist(mcols(alkt_lnc_rpkm)$gene_id)))
Venkat Malladi's avatar
Venkat Malladi committed
1280

1281
# SNORNA Genes
Venkat Malladi's avatar
Venkat Malladi committed
1282 1283 1284 1285 1286
ALKT_RNA_counts_sno <- ALKT_RNA1_counts_sno$counts +  ALKT_RNA2_counts_sno$counts
ALKT_RNA_lib_sno <- ALKT_RNA1_counts_sno$lib +  ALKT_RNA1_counts_sno$lib
ALKT_RNA_sno_d <- DGEList(counts=as.matrix(ALKT_RNA_counts_sno), lib.size=ALKT_RNA_lib_sno)
ALKT_RNA_sno_rpkm <- data.frame(rpkm(ALKT_RNA_sno_d,width(sno_tx)))
alkt_sno_rpkm <- sno_tx[ALKT_RNA_sno_rpkm>=1]
1287 1288

alkt_sno_expressed_transcripts <- NROW(unique(unlist(mcols(alkt_sno_rpkm)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301

ALKT_RIP_PARP_counts_sno <- ALKT_RIP_PARP1_counts_sno$counts +  ALKT_RIP_PARP2_counts_sno$counts
ALKT_RIP_PARP_lib_sno<- ALKT_RIP_PARP1_counts_sno$lib +  ALKT_RIP_PARP2_counts_sno$lib
ALKT_RIP_PI_counts_sno <- ALKT_RIP_PI1_counts_sno$counts +  ALKT_RIP_PI2_counts_sno$counts
ALKT_RIP_PI_lib_sno <- ALKT_RIP_PI1_counts_sno$lib +  ALKT_RIP_PI1_counts_sno$lib
ALKT_RIP_PI_d <- DGEList(counts=as.matrix(ALKT_RIP_PI_counts_sno), lib.size=ALKT_RIP_PI_lib_sno)
ALKT_RIP_PI_rpkm <- data.frame(rpkm(ALKT_RIP_PI_d,width(sno_tx)))
ALKT_RIP_PARP_d <- DGEList(counts=as.matrix(ALKT_RIP_PARP_counts_sno), lib.size=ALKT_RIP_PARP_lib_sno)
ALKT_RIP_PARP_rpkm <- data.frame(rpkm(ALKT_RIP_PARP_d,width(sno_tx)))


ALKT_RIP_FC <- data.frame((ALKT_RIP_PARP_rpkm+1)/(ALKT_RIP_PI_rpkm+1))
alkt_sno_rpkm_fc <- sno_tx[ALKT_RNA_sno_rpkm>=1 & ALKT_RIP_FC>=2 ]
1302 1303

alkt_sno_bound_transcripts <- NROW(unique(unlist(mcols(alkt_sno_rpkm_fc)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
1304 1305 1306 1307 1308 1309
sno_ratio <- NROW(unique(unlist(mcols(alkt_sno_rpkm_fc)$tx_name)))/NROW(unique(unlist(mcols(alkt_sno_rpkm)$tx_name)))

ALKT_RIP_sno <- data.frame(ALKT_RIP_PI_rpkm,ALKT_RIP_PARP_rpkm)
colnames(ALKT_RIP_sno) <- c('PI', 'PARP1')
ALKT_RIP_sno_rpkm <- ALKT_RIP_sno[ALKT_RNA_sno_rpkm>=1 & ALKT_RIP_FC>=2,]

1310
# SNRNA Genes
Venkat Malladi's avatar
Venkat Malladi committed
1311 1312 1313 1314 1315
ALKT_RNA_counts_sn <- ALKT_RNA1_counts_sn$counts +  ALKT_RNA2_counts_sn$counts
ALKT_RNA_lib_sn <- ALKT_RNA1_counts_sn$lib +  ALKT_RNA1_counts_sn$lib
ALKT_RNA_sn_d <- DGEList(counts=as.matrix(ALKT_RNA_counts_sn), lib.size=ALKT_RNA_lib_sn)
ALKT_RNA_sn_rpkm <- data.frame(rpkm(ALKT_RNA_sn_d,width(sn_tx)))
alkt_sn_rpkm <- sn_tx[ALKT_RNA_sn_rpkm>=1]
1316 1317

alkt_sn_expressed_transcripts <- NROW(unique(unlist(mcols(alkt_sn_rpkm)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330

ALKT_RIP_PARP_counts_sn <- ALKT_RIP_PARP1_counts_sn$counts +  ALKT_RIP_PARP2_counts_sn$counts
ALKT_RIP_PARP_lib_sn<- ALKT_RIP_PARP1_counts_sn$lib +  ALKT_RIP_PARP2_counts_sn$lib
ALKT_RIP_PI_counts_sn <- ALKT_RIP_PI1_counts_sn$counts +  ALKT_RIP_PI2_counts_sn$counts
ALKT_RIP_PI_lib_sn <- ALKT_RIP_PI1_counts_sn$lib +  ALKT_RIP_PI1_counts_sn$lib
ALKT_RIP_PI_d <- DGEList(counts=as.matrix(ALKT_RIP_PI_counts_sn), lib.size=ALKT_RIP_PI_lib_sn)
ALKT_RIP_PI_rpkm <- data.frame(rpkm(ALKT_RIP_PI_d,width(sn_tx)))
ALKT_RIP_PARP_d <- DGEList(counts=as.matrix(ALKT_RIP_PARP_counts_sn), lib.size=ALKT_RIP_PARP_lib_sn)
ALKT_RIP_PARP_rpkm <- data.frame(rpkm(ALKT_RIP_PARP_d,width(sn_tx)))

ALKT_RIP_FC <- data.frame((ALKT_RIP_PARP_rpkm+1)/(ALKT_RIP_PI_rpkm+1))
alkt_sn_rpkm_fc <- sn_tx[ALKT_RNA_sn_rpkm>=1 & ALKT_RIP_FC>=2 ]

1331
alkt_sn_bound_transcripts <- NROW(unique(unlist(mcols(alkt_sn_rpkm_fc)$tx_name)))
Venkat Malladi's avatar
Venkat Malladi committed
1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342
sn_ratio <- NROW(unique(unlist(mcols(alkt_sn_rpkm_fc)$tx_name)))/NROW(unique(unlist(mcols(alkt_sn_rpkm)$tx_name)))

ALKT_RIP_sn <- data.frame(ALKT_RIP_PI_rpkm,ALKT_RIP_PARP_rpkm)
colnames(ALKT_RIP_sn) <- c('PI', 'PARP1')
ALKT_RIP_sn_rpkm <- ALKT_RIP_sn[ALKT_RNA_sn_rpkm>=1 & ALKT_RIP_FC>=2,]

alkt_allsno <- c(alkt_sno_rpkm_fc,alkt_sn_rpkm_fc)
alkt_allsno_rpkm <- rbind(ALKT_RIP_sno_rpkm,ALKT_RIP_sn_rpkm)
allsno_rna <- c(sno_tx,sn_tx)
alkt_allsno_rna_rpkm <- rbind(ALKT_RNA_sno_rpkm,ALKT_RNA_sn_rpkm)

1343
# bar plot Species SNORNA
Venkat Malladi's avatar
Venkat Malladi committed
1344
# Grouped Bar Plot
1345
jpeg('figures/barchart-ac16-tnf-species.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
1346 1347 1348 1349 1350 1351 1352
ratios <- c(pc_ratio,lnc_ratio,sno_ratio,sn_ratio)
barplot(ratios, main="SNORNA AC16 TNF", col=c("red","black", "dimgrey", "lightgrey"),ylim=c(0,.5))
dev.off()

boundTesting <-matrix(c(1644,5047,225,249),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("mRNA", "snoRNA")))
fisher.test(boundTesting)

1353 1354
# Boxplot of Preimmune vs PARP-1
jpeg('figures/boxplot-ac16-tnf-species.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
1355 1356 1357
boxplot(ALKT_RIP_sno_rpkm,col=(c("orange","blue")),outline=FALSE,ylim = c(0,400),yaxt="n", cex.axis=1,las=2,lwd=4,lty=1)
axis(2, at=seq(0,400,100))
dev.off()
1358

Venkat Malladi's avatar
Venkat Malladi committed
1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369
wilcox.test(ALKT_RIP_sno_rpkm[,1], ALKT_RIP_sno_rpkm[,2],paired=T)


# Get Categories of  snoRNA
alkt_gr_snotx <- data.frame(seqnames=seqnames(alkt_sno_rpkm),
  starts=start(alkt_sno_rpkm)-1,
  ends=end(alkt_sno_rpkm),
  strand=strand(alkt_sno_rpkm),
  tx_name = elementMetadata(alkt_sno_rpkm)$tx_name,
  gene_id = unlist(elementMetadata(alkt_sno_rpkm)$gene_id))

1370
sno_annotations <- read.table('reference_annotations/RNA_small_nucleolar.txt',header = TRUE, sep = "\t")
Venkat Malladi's avatar
Venkat Malladi committed
1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391
sno_inx <- match(matrix(unlist(strsplit(as.character(alkt_gr_snotx$gene_id),split='.',fixed=T)),ncol=2,byrow=T)[,1], sno_annotations$ensembl_gene_id)
alkt_gr_snotx$symbol <- as.character(sno_annotations[sno_inx,"symbol"])
alkt_gr_snotx$gene_family <- as.character(sno_annotations[sno_inx,"gene_family"])
alkt_gr_snotx$gene_family[alkt_gr_snotx$gene_family == "Small nucleolar RNAs, H/ACA box"] <- "H/ACA box"
alkt_gr_snotx$gene_family[alkt_gr_snotx$gene_family == "Small nucleolar RNAs, C/D box"] <- "C/D box"
alkt_gr_snotx$gene_family[alkt_gr_snotx$gene_family == "Small Cajal body-specific RNAs"] <- "scaRNA"
alkt_gr_snotx$gene_family[alkt_gr_snotx$gene_family == ""] <- "Other"
alkt_gr_snotx$gene_family[is.na(alkt_gr_snotx$gene_family)] <- "Other"

ha_rna <- dim(alkt_gr_snotx[alkt_gr_snotx$gene_family == "H/ACA box",])[1]
cd_rna <- dim(alkt_gr_snotx[alkt_gr_snotx$gene_family == "C/D box",])[1]
sc_rna <- dim(alkt_gr_snotx[alkt_gr_snotx$gene_family == "scaRNA",])[1]

dat = data.frame(count=c(ha_rna, cd_rna, sc_rna), category=c("H/ACA box", "C/D box", "scaRNA"))
dat$fraction = dat$count / sum(dat$count)

dat$ymax = cumsum(dat$fraction)
dat$ymin = c(0, head(dat$ymax, n=-1))

dat$category <- factor(dat$category, levels = c("H/ACA box", "C/D box", "scaRNA"))

1392 1393
# Pie Chart SNORNA Species
jpeg('figures/piechart-ac16-tnf-species.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424
ggplot(dat, aes(fill=category, ymax=ymax, ymin=ymin, xmax=4, xmin=2)) +
  geom_rect(fill=c('darkorchid1', "darkorange1","darkgreen")) +
   coord_polar(theta="y") +
   xlim(c(0, 4)) +
   theme_bw() +
   theme(panel.grid=element_blank()) +
   theme(axis.text=element_blank()) +
   theme(axis.ticks=element_blank())
dev.off()


alkt_gr_snotx <- data.frame(seqnames=seqnames(alkt_sno_rpkm_fc),
  starts=start(alkt_sno_rpkm_fc)-1,
  ends=end(alkt_sno_rpkm_fc),
  strand=strand(alkt_sno_rpkm_fc),
  tx_name = elementMetadata(alkt_sno_rpkm_fc)$tx_name,
  gene_id = unlist(elementMetadata(alkt_sno_rpkm_fc)$gene_id))

sno_inx <- match(matrix(unlist(strsplit(as.character(alkt_gr_snotx$gene_id),split='.',fixed=T)),ncol=2,byrow=T)[,1], sno_annotations$ensembl_gene_id)
alkt_gr_snotx$symbol <- as.character(sno_annotations[sno_inx,"symbol"])
alkt_gr_snotx$gene_family <- as.character(sno_annotations[sno_inx,"gene_family"])
alkt_gr_snotx$gene_family[alkt_gr_snotx$gene_family == "Small nucleolar RNAs, H/ACA box"] <- "H/ACA box"
alkt_gr_snotx$gene_family[alkt_gr_snotx$gene_family == "Small nucleolar RNAs, C/D box"] <- "C/D box"
alkt_gr_snotx$gene_family[alkt_gr_snotx$gene_family == "Small Cajal body-specific RNAs"] <- "scaRNA"
alkt_gr_snotx$gene_family[alkt_gr_snotx$gene_family == ""] <- "Other"
alkt_gr_snotx$gene_family[is.na(alkt_gr_snotx$gene_family)] <- "Other"

ha_rip <- dim(alkt_gr_snotx[alkt_gr_snotx$gene_family == "H/ACA box",])[1]
cd_rip <- dim(alkt_gr_snotx[alkt_gr_snotx$gene_family == "C/D box",])[1]
sc_rip<- dim(alkt_gr_snotx[alkt_gr_snotx$gene_family == "scaRNA",])[1]

1425
# bar plot SNO RNA Types
Venkat Malladi's avatar
Venkat Malladi committed
1426
# Bar plot
1427
jpeg('figures/barchart-ac16-tnf-species_snospecies.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443
ratios <- c(sn_ratio,ha_rip/ha_rna,cd_rip/cd_rna,sc_rip/sc_rna)
barplot(ratios, main="snoRNA species AC16 TNF", col=c('pink1','darkorchid1', "darkorange1","darkgreen"),ylim=c(0,1))
dev.off()

typeTesting <-matrix(c(68,14,61,98),nrow = 2,dimnames = list(Guess = c("bound", "unbound"),Truth = c("HA", "CD")))
fisher.test(typeTesting)

# Combine snRNA and snoRNA and print out
allsnotx_tnf <- data.frame(seqnames=seqnames(alkt_allsno),
  starts=start(alkt_allsno)-1,
  ends=end(alkt_allsno),
  strand=strand(alkt_allsno),
  tx_id = elementMetadata(alkt_allsno)$tx_name,
  gene_id = unlist(elementMetadata(alkt_allsno)$gene_id))

allsnotx_tnf_rpkm <- cbind(allsnotx_tnf,alkt_allsno_rpkm)
1444 1445
sno_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snoRNA_mapping.txt", header=F, sep=',')
sn_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snRNA_mapping.txt", header=F, sep=',')
Venkat Malladi's avatar
Venkat Malladi committed
1446 1447 1448 1449
gencode_sn_mapping <-rbind(sno_mapping,sn_mapping)
sn_inx <- match(allsnotx_tnf_rpkm$tx_id, gencode_sn_mapping$V2)
allsnotx_tnf_rpkm$tx_name <- as.character(gencode_sn_mapping[sn_inx,"V4"])
allsnotx_tnf_rpkm$gene_name <- as.character(gencode_sn_mapping[sn_inx,"V3"])
1450
write.table(allsnotx_tnf_rpkm, file="tables/ac16-tnf-snRNA_RPKM_1_FC_2.tsv", quote=F, sep="\t", row.names=F, col.names=T)
Venkat Malladi's avatar
Venkat Malladi committed
1451 1452 1453 1454 1455 1456 1457 1458 1459

allsnotx_rna <- data.frame(seqnames=seqnames(allsno_rna),
  starts=start(allsno_rna)-1,
  ends=end(allsno_rna),
  strand=strand(allsno_rna),
  tx_id = elementMetadata(allsno_rna)$tx_name,
  gene_id = unlist(elementMetadata(allsno_rna)$gene_id))

alkt_allsnotx_rna_rpkm <- cbind(allsnotx_rna,alkt_allsno_rna_rpkm)
1460 1461
sno_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snoRNA_mapping.txt", header=F, sep=',')
sn_mapping <- read.csv("reference_annotations/gencode.v19.annotation_snRNA_mapping.txt", header=F, sep=',')
Venkat Malladi's avatar
Venkat Malladi committed
1462 1463 1464 1465
gencode_sn_mapping <-rbind(sno_mapping,sn_mapping)
sn_inx <- match(alkt_allsnotx_rna_rpkm$tx_id, gencode_sn_mapping$V2)
alkt_allsnotx_rna_rpkm$tx_name <- as.character(gencode_sn_mapping[sn_inx,"V4"])
alkt_allsnotx_rna_rpkm$gene_name <- as.character(gencode_sn_mapping[sn_inx,"V3"])
1466
write.table(alkt_allsnotx_rna_rpkm, file="tables/ac16-tnf-snRNA_RPKM_RNA.tsv", quote=F, sep="\t", row.names=F, col.names=T)
Venkat Malladi's avatar
Venkat Malladi committed
1467 1468 1469 1470 1471 1472

```

# Overlap of snoRNA and snRNA
``` {r snoRNA Overlap}

1473
# Overlap SNORNA AC16 Basal and TNF
Venkat Malladi's avatar
Venkat Malladi committed
1474 1475 1476
ac16_unique <- unique(alk_gr_snotx$tx_name)
tnf_unique <- unique(alkt_gr_snotx$tx_name)
overlap <- calculate.overlap(x = list("Basal" = ac16_unique,"TNF" = tnf_unique))
1477
jpeg('figures/venndigram_ac16_basal_tnf_snoRNA.jpg')
Venkat Malladi's avatar
Venkat Malladi committed
1478 1479 1480
draw.pairwise.venn(area1 = length(overlap$a1), area2 = length(overlap$a2), cross.area = length(overlap$a3),col = c("royalblue4", "seagreen4"),lwd=4)
dev.off()
```