Question: Heatmap: how to just show significantly differentially expressed transcripts in it ?
0
gravatar for Farbod
3.8 years ago by
Farbod3.3k
Toronto
Farbod3.3k wrote:

Dear Biostars, Hi

I have about 8000 transcripts that has hit with Transcription Factors (TFs). Among them 69 are up-regulated in females (3 biological replication) and 19 up-regulated in males (with 3 biological replication). (using DESeq2, FDR 0.05)

Now I intend to draw a heat map based on my TMM-normalized expression values (3 for males and 3 for females for each transcripts) but I want to just show the DEG in it (69+19) not all 8000 transcripts; something same as Figure8b in here.

1) How can I do it? is it just by selecting those 88 transcripts TMM value and used them as input in R heatmap script?

2) As you can see in the Figure8, there is just 2 columns. but as I have 3 BR for each conditions, I have 6 columns. How I can convert them into 2 columns ?

Can I calculate the mean of each 3 TMM of each transcripts and use the mean number as input for each transcripts ?

~ Thank you in advance

ADD COMMENTlink modified 3.8 years ago by TriS4.2k • written 3.8 years ago by Farbod3.3k
3
gravatar for TriS
3.8 years ago by
TriS4.2k
United States, Buffalo
TriS4.2k wrote:

1) How can I do it? is it just by selecting those 88 transcripts TMM value and used them as input in R heatmap script?

create a matrix containing only the genes you are interested in and use that for your heatmap. you can easily do that in R (assuming genes in rows and samples in columns):

m <- myMatrixWithResults
index_genes <- which(rownames(m) %in% myListOfGenes)
sub_m <- m[index_m,]

2) As you can see in the Figure8, there is just 2 columns. but as I have 3 BR for each conditions, I have 6 columns. How I can convert them into 2 columns ?

I would prize you for showing all replicates to show that your results are consistent. I'd suggest to scale/center the data and use this matrix for heatmap. for the image itself you can use pheatmap, which is straightforward and offers pretty coloring options, including scaling the data.

ADD COMMENTlink modified 3.8 years ago • written 3.8 years ago by TriS4.2k

Dear @TriS, Hi and thanks for your help

1- My data are matrix of TMM-normalized expression values as produced by Trinity. Do I need to "scale/center the data" in this case ? if yes What exactly you mean by this?

2- I want ti use this color scheme. Do you know how to import it in the script of heatmap in R ?

3- I found this heatmap example very pretty but there is many error is running it.

~ Take Care

ADD REPLYlink modified 3.8 years ago • written 3.8 years ago by Farbod3.3k
1

1- you can use pheatmap(myData,scale="row") 2- use color=colorRampPalette(c("#fee8c8", "#fdbb84", "#e34a33"))(100),breaks=seq(-2,2,length=100) within the pheatmap function 3- without your code it's impossible to say why you get the error

ADD REPLYlink written 3.8 years ago by TriS4.2k

Dear TriS,

Thank for all your helps and very useful guidance.

One problem that I have encountred is this that when I run my script (below), I could not see my 88 transcripts ID in my heat map (e.g TRINITY_DN107669_c1_g2_i1)

Would you please help me about it ? ( I even have tried my_matrix <- t(my_matrix) but no chance!)

this is head of head(my_data):

                samples    F1    F2    F3    M1    M2    M3

1 TRINITY_DN107669_c1_g2_i1 2.120 0.173 0.781 0.000 0.000 0.000

2 TRINITY_DN101742_c5_g1_i2 0.398 0.303 0.751 0.000 0.009 0.000

3 TRINITY_DN107731_c4_g1_i4 0.102 0.336 0.160 0.000 0.000 0.000

And this is my R script for Heatmap :

library(ComplexHeatmap)
library(pheatmap)
filename <- "male-female-88-TMM.matrix"
my_data <- read.table(filename, sep='\t', quote='', stringsAsFactors=FALSE, header=TRUE)
head(my_data)
dim(my_data)

row.names(my_data) <- d$sample
my_data <- my_data[, -1]
my_data <- my_data/rowSums(my_data)
my_matrix <- as.matrix(my_data) 

head(my_matrix)
samples_info <- data.frame(samples= my_data$samples)
pheatmap(my_matrix,scale="row", color=colorRampPalette(c("#fee8c8", "#fdbb84", "#e34a33"))(100),breaks=seq(-2,2,length=100))
ADD REPLYlink modified 3.8 years ago • written 3.8 years ago by Farbod3.3k

what does head(my_matrix) return?

ADD REPLYlink written 3.8 years ago by TriS4.2k

> dim(my_data)

[1] 88 7

> head(my_matrix)

         F1         F2        F3         M1          M2          M3

[1,] 0.68965517 0.05627846 0.2540664 0.00000000 0.000000000 0.000000000

[2,] 0.27241615 0.20739220 0.5140315 0.00000000 0.006160164 0.000000000

[3,] 0.17056856 0.56187291 0.2675585 0.00000000 0.000000000 0.000000000

ADD REPLYlink modified 3.8 years ago • written 3.8 years ago by Farbod3.3k
1

you don't see the sample names because you don't have rownames :)

ADD REPLYlink written 3.8 years ago by TriS4.2k

Dear TriS, Hi

I have corrected the rownames, finally. ;-)

actually it was in my script but as I have copied this script from different references, I have used d instead of my data in my script. so;

incorrect : row.names(my_data) <- d$sample

correct : row.names(my_data) <- my_data$sample

Now I have another label for rows; in addition to transcripts IDS (TRINITY bla bla bla), I have the gene names that showed in annotation and I want to add them in the different side of the rows (left side the IDs and right side the blast hits).

1) How can I do it ? did I must add another column to my original file containing the gene names or I can insert these lables from separate file ?

2) I have seen a shrink option in some heatmaps. have you any experience about using it in Heatmap() ?

3) in your first script (index_genes <- which(rownames(m) %in% myListOfGenes)) you kindly have shared with me, what did %in% myListOfGenes mean?

ADD REPLYlink modified 3.8 years ago • written 3.8 years ago by Farbod3.3k
1
  1. I personally don't know a way to add a second column with the different rownames as text.
  2. never used it
  3. the "%in%" command allows you to look for something into something else, and returns the index with the position(s) of the element(s) in the array you searched. in that case I assumed you had a list of gene names in myListOfGenes and looked at where those were rownames of the matrix m...this is a pretty basic R command, I would suggest you to check out some online tutorials and play a little with value matching
ADD REPLYlink written 3.8 years ago by TriS4.2k

Hi again,

I need to show my 88 row names at the side that I am showing my clustering/dendrogram (left side).

They are now on the opposite sides.

in Heatmap(), it could be done using row_names_side = "left"androw_hclust_side = "left",BUT I want its option in heatmap() and pheatmap().

Do you have any suggestion dear TriS ?

ADD REPLYlink modified 3.8 years ago • written 3.8 years ago by Farbod3.3k
1

hi Farbod, I am not sure how to do that, it might be useful to start a new thread with that question since it's drifting away from your initial problem

ADD REPLYlink written 3.8 years ago by TriS4.2k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1342 users visited in the last hour