forked from dasenlab/Pbx-Neuron-Paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDasen_RNAseq_report_brachial_thoracic_overlap.Rmd
230 lines (196 loc) · 8.53 KB
/
Dasen_RNAseq_report_brachial_thoracic_overlap.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
---
title: Dasen lab, Pbx-mutant RNAseq, brachial and thoracic overlap
author: "Lisa J. Cohen"
output: html_document
---
Filenames for brachial-level transcripts are here:
```{r,echo=FALSE, message=FALSE, warning=FALSE}
library(DESeq2)
library("genefilter")
library(gplots)
library(RColorBrewer)
library(biomaRt)
library("genefilter")
library("lattice")
setwd("~/Documents/NYUMC/Dasen/brachial/htseq_counts")
mypath<-"~/Documents/NYUMC/Dasen/brachial/htseq_counts"
filenames<-list.files(path=mypath, pattern= "_counts.txt", full.names=FALSE)
datalist <-lapply(filenames, function(x){read.table(x,header=FALSE, sep="\t")})
for (i in 1:length(filenames))
{
colnames(datalist[[i]])<-c("ID",filenames[[i]])
}
mergeddata <- Reduce(function(x,y) {merge(x,y, by="ID")}, datalist)
new_data_merge<-mergeddata[-1:-5,]
#write.csv(new_data_merge,file="Dasen_thoracic_count_data_Ensembl.csv")
rown<-new_data_merge$ID
rownames(new_data_merge)<-rown
new_data_merge<-new_data_merge[,-1]
data<-new_data_merge
colnames(data)
col.names<-c("BR-A-Control","BR-A-Mutant","BR-B-Control","BR-B-Mutant","BR-C-Control","BR-C-Mutant")
colnames(data)<-col.names
thoracic_data<-data
ExpDesign <- data.frame(row.names=colnames(thoracic_data), condition = c("Control","Mutant","Control","Mutant","Control","Mutant"))
cds<-DESeqDataSetFromMatrix(countData=data, colData=ExpDesign,design=~condition)
cds$condition <- relevel(cds$condition, "Control")
cds<-DESeq(cds, betaPrior=FALSE)
cds_brachial<-cds
```
Filenames for thoracic-level transcripts are here:
```{r,echo=FALSE, message=FALSE, warning=FALSE}
setwd("~/Documents/NYUMC/Dasen/thoracic/htseq_counts")
mypath<-"~/Documents/NYUMC/Dasen/thoracic/htseq_counts"
filenames<-list.files(path=mypath, pattern= "_counts.txt", full.names=FALSE)
datalist <-lapply(filenames, function(x){read.table(x,header=FALSE, sep="\t")})
for (i in 1:length(filenames))
{
colnames(datalist[[i]])<-c("ID",filenames[[i]])
}
mergeddata <- Reduce(function(x,y) {merge(x,y, by="ID")}, datalist)
new_data_merge<-mergeddata[-1:-5,]
#write.csv(new_data_merge,file="Dasen_thoracic_count_data_Ensembl.csv")
rownames(new_data_merge)<-new_data_merge$ID
new_data_merge<-new_data_merge[,-1]
data<-new_data_merge
colnames(data)
col.names<-c("TH-A-Control","TH-A-Mutant","TH-B-Control","TH-B-Mutant","TH-C-Control","TH-C-Mutant")
colnames(data)<-col.names
brachial_data<-data
ExpDesign <- data.frame(row.names=colnames(brachial_data), condition = c("Control","Mutant","Control","Mutant","Control","Mutant"))
cds<-DESeqDataSetFromMatrix(countData=data, colData=ExpDesign,design=~condition)
cds$condition <- relevel(cds$condition, "Control")
cds<-DESeq(cds,betaPrior=FALSE)
cds_thoracic<-cds
```
The size of the table with all brachial transcripts is:
```{r,echo=FALSE, message=FALSE, warning=FALSE}
# get norm counts
norm_counts<-counts(cds_brachial,normalized=TRUE)
norm_counts_data<-as.data.frame(norm_counts)
ensembl_id<-rownames(norm_counts)
norm_counts_data<-cbind(ensembl_id,norm_counts_data)
filtered_norm_counts<-norm_counts_data[!rowSums(norm_counts_data[,2:7]==0)>=1, ]
# get gene name from Ensembl gene ID
ensembl=useMart("ensembl")
ensembl = useDataset("mmusculus_gene_ensembl",mart=ensembl)
data_table<-filtered_norm_counts
query<-getBM(attributes=c('ensembl_gene_id','external_gene_name','gene_biotype'), filters = 'ensembl_gene_id', values = ensembl_id, mart=ensembl)
col.names<-c("ensembl_id","external_gene_id","gene_biotype")
colnames(query)<-col.names
merge_biomart_res_counts <- merge(data_table,query,by="ensembl_id")
temp_data_merged_counts<-merge_biomart_res_counts
##
res<-results(cds_brachial,contrast=c("condition","Mutant","Control"))
res_ordered<-res[order(res$padj),]
ensembl_id<-rownames(res_ordered)
res_ordered<-as.data.frame(res_ordered)
res_ordered<-cbind(res_ordered,ensembl_id)
merge_biomart_res_counts <- merge(temp_data_merged_counts,res_ordered,by="ensembl_id")
merge_biomart_res_all<-subset(merge_biomart_res_counts,merge_biomart_res_counts$padj!="NA")
merge_biomart_res_all<-merge_biomart_res_all[order(merge_biomart_res_all$padj),]
dim(merge_biomart_res_all)
```
The size of the brachial table with only significant transcripts, padj<0.05 is:
```{r,echo=FALSE, message=FALSE, warning=FALSE}
res_merged_cutoff<-subset(merge_biomart_res_all,merge_biomart_res_all$padj<0.05)
dim(res_merged_cutoff)
res1_filtered_padj<-res_merged_cutoff
```
The size of the table with all thoracic transcripts is:
```{r,echo=FALSE, message=FALSE, warning=FALSE}
# get norm counts
norm_counts<-counts(cds_thoracic,normalized=TRUE)
norm_counts_data<-as.data.frame(norm_counts)
ensembl_id<-rownames(norm_counts)
norm_counts_data<-cbind(ensembl_id,norm_counts_data)
filtered_norm_counts<-norm_counts_data[!rowSums(norm_counts_data[,2:7]==0)>=1, ]
# get gene name from Ensembl gene ID
ensembl=useMart("ensembl")
ensembl = useDataset("mmusculus_gene_ensembl",mart=ensembl)
data_table<-filtered_norm_counts
query<-getBM(attributes=c('ensembl_gene_id','external_gene_name','gene_biotype'), filters = 'ensembl_gene_id', values = ensembl_id, mart=ensembl)
col.names<-c("ensembl_id","external_gene_id","gene_biotype")
colnames(query)<-col.names
merge_biomart_res_counts <- merge(data_table,query,by="ensembl_id")
temp_data_merged_counts<-merge_biomart_res_counts
##
res<-results(cds_thoracic,contrast=c("condition","Mutant","Control"))
res_ordered<-res[order(res$padj),]
ensembl_id<-rownames(res_ordered)
res_ordered<-as.data.frame(res_ordered)
res_ordered<-cbind(res_ordered,ensembl_id)
merge_biomart_res_counts <- merge(temp_data_merged_counts,res_ordered,by="ensembl_id")
merge_biomart_res_all<-subset(merge_biomart_res_counts,merge_biomart_res_counts$padj!="NA")
merge_biomart_res_all<-merge_biomart_res_all[order(merge_biomart_res_all$padj),]
dim(merge_biomart_res_all)
```
The size of the thoracic table with only significant transcripts, padj<0.05 is:
```{r,echo=FALSE, message=FALSE, warning=FALSE}
res_merged_cutoff<-subset(merge_biomart_res_all,merge_biomart_res_all$padj<0.05)
dim(res_merged_cutoff)
res2_filtered_padj<-res_merged_cutoff
```
# Venn Diagram
```{r,echo=FALSE, message=FALSE, warning=FALSE}
source('~/Documents/scripts/overLapper_original.R')
# brachial
m<-res1_filtered_padj$external_gene_id
# thoracic
n<-res2_filtered_padj$external_gene_id
setlist <- list(Brachial_v_Control=as.vector(m),Thoracic_v_Control=as.vector(n))
OLlist <- overLapper(setlist=setlist, sep="", type="vennsets")
counts <- sapply(OLlist$Venn_List, length)
vennPlot(counts=counts)
```
```{r,echo=FALSE, message=FALSE, warning=FALSE}
# extract intersections for up:
Brachial_Thoracic<-OLlist$Venn_List$Brachial_v_ControlThoracic_v_Control
Brachial_Overlap<-res1_filtered_padj[res1_filtered_padj$external_gene_id %in% Brachial_Thoracic,]
Thoracic_Overlap<-res2_filtered_padj[res2_filtered_padj$external_gene_id %in% Brachial_Thoracic,]
Brachial_Thoracic_results<-merge(Brachial_Overlap,Thoracic_Overlap,by="ensembl_id")
```
# Heatmap
```{r,echo=FALSE, message=FALSE, warning=FALSE}
d<-as.matrix(Brachial_Thoracic_results[,c(2:7,16:21)])
rownames(d) <- Brachial_Thoracic_results[,8]
d<-na.omit(d)
d<-d[,c(1,3,5,2,4,6,7,9,11,8,10,12)]
colnames(d)<-c("BR-A-Control","BR-B-Control","BR-C-Control","BR-A-Mutant","BR-B-Mutant","BR-C-Mutant","TH-A-Control","TH-B-Control","TH-C-Control","TH-A-Mutant","TH-B-Mutant","TH-C-Mutant")
hr <- hclust(as.dist(1-cor(t(d), method="pearson")), method="complete")
mycl <- cutree(hr, h=max(hr$height/1.5))
clusterCols <- rainbow(length(unique(mycl)))
myClusterSideBar <- clusterCols[mycl]
myheatcol <- greenred(75)
#tiff("Overlap_heatmap.tiff", width = 1000,height = 1000,units="px",res = NA,pointsize=12)
heatmap.2(d,
Rowv=as.dendrogram(hr),
cexRow=1,cexCol=0.8,srtCol= 90,
adjCol = c(NA,0),offsetCol=2.5,offsetRow=0.1,
Colv=NA, dendrogram="row",
scale="row", col=myheatcol,
density.info="none",
trace="none")
#dev.off()
###
```
File:
```{r}
write.csv(Brachial_Thoracic_results,"Dasen_Brachial_Thoracic_merged_padj0.05.csv")
```
Versions:
```{r}
sessionInfo()
```
### Sequencing and original bioinformatics analysis by:
NYU Langone Medical Center
Bioinformatics Core, Genome Technology Center, OCS
Email: [email protected]
Phone: 646-501-2834
http://ocs.med.nyu.edu/bioinformatics-core
http://ocs.med.nyu.edu/genome-technology-center
# References
M. I. Love, W. Huber, S. Anders: Moderated estimation of fold change and dispersion for RNA-seq data with DESeq2.
Genome Biology 2014, 15:550. http://dx.doi.org/10.1186/s13059-014-0550-8
R-Bioconductor: http://www.bioconductor.org/
DESeq2: http://www.bioconductor.org/packages/release/bioc/vignettes/DESeq2/inst/doc/DESeq2.pdf