Question: RStudio Pheatmap: sort DEG by logFC
0
gravatar for chienjen113
4 weeks ago by
chienjen1130 wrote:

Hi Guys,

I'm very new to R and bioinformatics and I hope my question isnt that stupid... I'm trying to make a Heatmap with 200 DEGs from an RNA_Seq_Dataset. In my script (which I got from another PhD candidate) I've got the following code:

topVarianceGenes <- head(order(rowVars(assay(rld)), decreasing=T),200)
matrix <- assay(rld)[topVarianceGenes,]
matrix <- matrix - rowMeans(matrix)


annotation_data <- as.data.frame(colData(rld))
pheatmap(matrix, scale = 'row',
         show_rownames = T,
         color = bluered(100),
         fontsize = 8,
         annotation_col = annotation_data[1],
         cluster_cols = F) `

It works quite well, but I'm told to use the Top Genes sort by logFC and I don't find anything using google or the search function in thi forum.

Thanks to anyone who could help! :)

rna-seq R • 127 views
ADD COMMENTlink modified 28 days ago by genomax87k • written 4 weeks ago by chienjen1130

Hi,

Can you post the code that you've used before and print the first few lines of your data?

For instance I don't know how it looks your data, so I don't know that column names, and so on. I believe that you've used DESeq2 for DEG, but it's not clear to me.

António

ADD REPLYlink written 4 weeks ago by antonioggsousa870

From the code, it seems earlier dev used DESeq2 analysis. Please follow the manual of DEseq2 here: http://bioconductor.org/packages/devel/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#heatmap-of-the-count-matrix

ADD REPLYlink modified 4 weeks ago • written 4 weeks ago by cpad011213k

Hi,

Thank you very much, I just had to change a few things and it worked :)

ADD REPLYlink written 28 days ago by chienjen1130

Please make a note of things you changed and perhaps post that as a new answer. This comment does not help future visitors. If @caggtaagtat's answer helped you solve the problem please upvote/accept that answer.

ADD REPLYlink written 28 days ago by genomax87k
0
gravatar for caggtaagtat
4 weeks ago by
caggtaagtat1.1k
caggtaagtat1.1k wrote:

Hi,

I also think, you use DESeq2. So if thats true, you could do something like this:

For the L2FC you need the call the result function first. With the abs function, you calculate the L2FC without + or -. So you then can sort by highest absolute L2FC value.

res_data <- results(ds_txi,contrast=c("treatment","Drug","Control"))

res_data$abs_L2FC <- abs(res_data$L2FC)

mat <- assay(rld)[head(order(res_data$abs_L2FC, decreasing=T),200), ]
mat <- mat - rowMeans(mat)
df <- as.data.frame(colData(vsd)[, c("treatment")])
rownames(df) <- colnames(mat)

pheatmap(mat, annotation_col = df, cluster_rows = F , show_colnames = F )
ADD COMMENTlink written 4 weeks ago by caggtaagtat1.1k
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: 1523 users visited in the last hour