sesame icon indicating copy to clipboard operation
sesame copied to clipboard

Legend for visualizeRegion/visualizeGene/visualizeProbes

Open alanlamsiu opened this issue 2 years ago • 10 comments

Is there a way to add the legend (color scale) when using visualizeRegion/visualizeGene/visualizeProbes? Thanks!

alanlamsiu avatar Aug 23 '22 19:08 alanlamsiu

Yes, you can add it with WLegendV or WLegendH to the resulting grid objects. something like

visualizeProbes(...) + WLegendV('betas', TopRightOf())

zwdzwd avatar Aug 23 '22 23:08 zwdzwd

Thanks for pointing to the WLegendV function. I tried it with visualizeGene() but it showed the "Error in objs[[1]] : subscript out of bounds" message. Do you think it has something to do with the betas object, which was generated by openSesame()?

alanlamsiu avatar Aug 24 '22 02:08 alanlamsiu

Can you try the following example?

betas <- sesameDataGet('HM450.10.TCGA.PAAD.normal')
visualizeGene('DNMT1', betas, platform='HM450') + WLegendV("betas", TopRightOf("betas"))

zwdzwd avatar Aug 24 '22 02:08 zwdzwd

Yes, this example works fine. I noticed that there were some probes with NAs and I thought thoese might be an issue. So I removed probes with NA, however, the subscript out of bounds error still occurred. If not adding WLegendV(), the figure was generated without any issue.

alanlamsiu avatar Aug 24 '22 03:08 alanlamsiu

One possibility is that there is no beta value heatmap after removing the NAs. If so, yeah, the legend might be struggling to find the original color scale.

zwdzwd avatar Aug 24 '22 03:08 zwdzwd

I would also suspect so. Below is what the heatmap looks like after removing the NAs. Yet, the "subscript out of bound" error persisted. image

alanlamsiu avatar Aug 24 '22 03:08 alanlamsiu

OK. If you can share with me an example to reproduce this, I can troubleshoot more.

zwdzwd avatar Aug 24 '22 12:08 zwdzwd

I extracted the beta values of 16 probes associated with the FMR1 gene as shown in this table. I tried to use this matrix as input for visualizeGene() and WLegendV() but the error message showed up on my end. Appreciate if you could look into the issue.

alanlamsiu avatar Aug 24 '22 14:08 alanlamsiu

can you try

betas = read_tsv("~/Downloads/test_betas.txt")
b2 = as.matrix(betas[,2:7])
rownames(b2) = betas[[1]]
visualizeGene("FMR1", b2, platform="EPIC") + WLegendV("betas", TopRightOf("betas"))

zwdzwd avatar Aug 24 '22 14:08 zwdzwd

It works now. I guess the trick is in the data type of betas/b2. Thanks Wanding for your help.

Just a note here. It worked for me if I first saved the probes to be plotted in a variable named "betas" and then plotted it using the "betas" variable. I tried to name it as "temp_betas" but it didn't work.

alanlamsiu avatar Aug 24 '22 15:08 alanlamsiu