how to plot heatmap with in cell type comparison using contrasts.
1
0
Entering edit mode
badribio • 0
@badribio-12724
Last seen 5.4 years ago

Previously i asked, this question deseq2 and dexseq for multiple tissue from wildtype only

 

Based on the response and some reading i used this design, 

 

sample

tissue

sample1

tissue1

sample1

tissue1

sample2

tissue2

sample2

tissue2

sample2

tissue2

sample3

tissue3

sample3

tissue3

sample4

tissue4

sample4

tissue4

sample5

tissue5

sample5

tissue5

sample5

tissue5

sample6

tissue6

sampl6

tissue6

sample6

tissue6

sample7

tissue7

sample7

tissue7

sample7

tissue7

 

#design

dds <- DESeqDataSetFromMatrix(countData = data,
                                     colData =colData,
                                     design = ~tissue)

dds <- estimateSizeFactors(dds)

#filter low counts
idx <-rowSums(counts(dds, normalize=TRUE) >= 19 ) >= 2
deseq2.dds <- dds[idx,]
dds <- DESeq(dds)

what i am trying to do next is compare tissue1 with every other tissue and compare tissue1 with tissue 2 , tissue 2 with 3 so on and so forth, using contrast function, 

#comparison 1

comp1 <- results(dds, contrast = c("tissue", "tissue1", "tissue2")) #similarly for others and write it to a text file.

 

 

I read each file again 

comp1.DE <-read.table("tissue1Vstissue2") #similarly for other comparsions
#create a matrix 

DE.mat<-cbind(comp1.DE[,c(1,2)],comp2.DE[,2],comp3.DE[,2],
              comp4.DE[,2],comp5.DE[,2],comp6.DE[,2]) #column 2 logfc
rownames(DE.mat)<-DE.mat$V1 #rownamesgeneid
colnames(DE.mat)<-c("Comp1", "Comp2", "Comp3", "Comp4", "Comp5", "Comp6")

DE.mat<-DE.mat[,-1]

pheatmap(DE.mat,fontsize_col=20, show_rownames=F)

This gives me all the the rows from each comparison 

what i would like help is when i filter each comparison on only significant genes after reading the files, 

 

comp1.DE <-read.table("tissue1Vstissue2.txt")

comp1.DE.f <- filter(comp1.DE, comp1.DE$padj < 0.01)#similarly for other comparisons

I end up with diffrent number of each for each comparison, and hence cannot plot heatmap. 

Is this a reasonable approach or is there an better approach, if yes could someone please help me with plotting heatmaps with different number of rows.

 

many thanks.  

 

 

deseq2 • 860 views
ADD COMMENT
2
Entering edit mode
@mikelove
Last seen 1 day ago
United States

The heatmap functions from various packages need matrices, so you can't filter the results table for each comparison and then combine those vectors of different length, that doesn't make a matrix, as you say.

You would need to produce a set of transcripts which is the union() of the rownames of each filtered results table, and then you can combine a subset of the results tables, using this union set.

ADD COMMENT
0
Entering edit mode

Thought so, was trying to push my luck here thank you

ADD REPLY

Login before adding your answer.

Traffic: 707 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6