Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anno gene in heatmap #43

Open
li1311139481 opened this issue Jun 30, 2024 · 4 comments
Open

anno gene in heatmap #43

li1311139481 opened this issue Jun 30, 2024 · 4 comments

Comments

@li1311139481
Copy link

Hello, thank you for your work.
I used the featureAlignedExtendSignal function to process differential peaks. Then I used featureAlignedHeatmap to create a heatmap.

sig <- featureAlignedExtendSignal(bamfiles = totalbamfiles, 
                                  feature.gr = reCenterPeaks(dbObj.report[1:1500], width=1), 
                                  upstream = upstream,
                                  downstream = downstream,
                                  n.tile=n.tile, 
                                  fragmentLength=fragmentLength,
                                  librarySize=librarySize)
peaks <- reCenterPeaks(dbObj.report[1:1500], width=1010)
peaks_Anno <- annotatePeak(peaks,
    TxDb = TxDb.Mmusculus.UCSC.mm10.knownGene,
    annoDb = "org.Mm.eg.db"
)
featureAlignedHeatmap(sig, peaks_Anno@anno, upper.extreme = maxvalue,
                      zeroAt=0.5, n.tile=n.tile,#annoMcols=c("anno_gene"),
                      color = colorRampPalette(rev(brewer.pal(n=7, name = "RdBu")))(100))

image

I get the result. but i want anno the heatmap using some gene. As you can see, my input is differential peaks, and i annotate the peaks to gene. If I only want to annotate the positions of Pdcd1 and Havcr2 genes in the heatmap, and if I use the annoMcols parameter to specify the SYMBOL column in peaks_Anno@anno, it will annotate all genes. This does not meet my needs. How can I clearly annotate the genes I want?
just like this
image

@hukai916
Copy link
Contributor

hukai916 commented Jul 1, 2024

Have you tried to mask the unwanted genes with "":

peaks_Anno@anno$anno_gene[!(peaks_Anno@anno$anno_gene %in% c("Pdcd1", "Havcr2"))] <- ""

@li1311139481
Copy link
Author

Have you tried to mask the unwanted genes with "":

peaks_Anno@anno$anno_gene[!(peaks_Anno@anno$anno_gene %in% c("Pdcd1", "Havcr2"))] <- ""

Thanks for your help
If I use "" to hide genes, I am actually grouping all the genes I don't need to annotate into one category. This would result in a huge anno_block. I don't know how to describe it, but in ComplexHeatmap it's called anno_block. While I want the genes I want to annotate to form a separate anno_block, its position is always squeezed to the top or bottom edge by the "" anno_block. And since a gene only represents one row, it is difficult to see where the annotated genes are located in the anno_block.

@hukai916
Copy link
Contributor

hukai916 commented Jul 1, 2024

The anno_block was caused by the sortBy argument in the featureAlignedHeatmap function, where it first sorts by annoMcols followed by the signals of the samples. That means, if you set sortBy = NULL, it won't create anno_block, but you will lose the ordering by signals too. You can input a pre-sorted feature.gr while setting sortBy = NULL to keep the ordering.

@li1311139481
Copy link
Author

Thank you for your reply.
I tried to use sortby=NULL, and understand how do you sorted. But featureAlignedSignal gave me a headache. I try to sort using the rowMeans of the first sample.

cvglists <- lapply(cvglists, function(x) {
    x <- x[names(sort(rowMeans(cvglists[[1]]),decreasing = T)),]
    return(x)
})
feature.gr <- peaks_Anno@anno[match(names(sort(rowMeans(cvglists[[1]]),decreasing = T)), peaks_Anno@anno$SYMBOL),]
featureAlignedHeatmap(cvglists, feature.gr, upper.extreme = maxvalue,
                      zeroAt=0.5, n.tile=n.tile,sortBy=NULL,annoMcols=c("anno_gene"),
                      color = colorRampPalette(rev(brewer.pal(n=7, name = "RdBu")))(100))

However. My order is so simple that it doesn't match the graph you drew
this is my
image
This is yours

featureAlignedHeatmap(cvglists, feature.gr, upper.extreme = maxvalue,
                      zeroAt=0.5, n.tile=n.tile,annoMcols=c("anno_gene"),
                      color = colorRampPalette(rev(brewer.pal(n=7, name = "RdBu")))(100))

image

In addition, anno_block is still created after I specify sortby=NULL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants