griffithlab / GenVisR

Genome data visualizations
Creative Commons Zero v1.0 Universal
209 stars 62 forks source link

change color key range in cnSpec #345

Open wangfan860 opened 6 years ago

wangfan860 commented 6 years ago

I found the color key range is always from -2 to 4. However, the copy number range of my data is from -1 to 2. How can I customize the range of color key? Many thanks in advance!

cedricvanm commented 6 years ago

Hi, I guess your copy number data are "relative" and not "absolute", meaning that diploidy is 0 ? If this is the case, you can use the argument CNscale.

Nevertheless, it's true that when performing a CN frequency plot, we can select the tresholds below or above which we consider a copy number a loss or a gain. It would be great if we could do the same in CNspec. Any chance this would be possible in an update ?

Thanks for this amazing package!

zlskidmore commented 6 years ago

That should be fairly easy to add, I'm actively working on an update to this package now, will be sure to incorporate this feature into cnSpec

wangfan860 commented 5 years ago

Is this problem solved already? So the range for relative scale is always -2 to 4; And for absolute is 0 to 4. I hope this range can change according to the real data. Is that possible? Thanks again!

zlskidmore commented 5 years ago

I have not got around to refactoring this function yet, though the CN plots are next on my list when I get the time.

Dagsbio commented 5 years ago

Hello all, I guess this hasn't been solved yet.

When it happens could you tell us please?

Thank you for developing this fantastic tool by the way!

zlskidmore commented 5 years ago

yes, am hoping to make a genvisr push in feb.

Dagsbio commented 5 years ago

Thats great!

By the way, Is there any way I can make the colors look stronger? turns out when I try to pick any other html color, the default colors doesn't change, like this would not have any effect:

cnSpec(arrays, genome="hg19", CN_Loss_colour = "#044DEA", CN_Gain_colour = "#CB4335", CNscale = "relative")

In the range -2 to 4, samples with value of 1, have a very weak red color

SereFe commented 3 years ago

Hello all, I am wondering whether this issue has been solved. There is a way to change the range for relative scale?

Thank you

sitapriyamoorthi commented 2 years ago

Yes could you please update this! It would be very helpful! Also is it possible to add a clustering feature as well!

sitapriyamoorthi commented 2 years ago

I tried one work around, basically run all the functions in R yourself and then edit range here (in bold) (in cnSpec_buildMain_2)

Define parameters of plot

facet <- facet_grid(sample ~ chromosome, scales='free', space='free')
if(CNscale == "absolute")
{
    fill_gradient <- scale_fill_gradientn("Copy Number",
                                          colours=c(CN_low_colour,
                                                    'white',
                                                    CN_high_colour),
                                          **values=scales::rescale(c(0, 1, 20))**,
                                          limits=c(0, 20),
                                          oob=scales::squish)
} else if(CNscale == "relative") {
    fill_gradient <- scale_fill_gradientn("Copy Number",
                                          colours=c(CN_low_colour,
                                                    "white",
                                                    CN_high_colour),
                                          values=scales::rescale(c(-2, 0, 4)),
                                          limits=c(-2, 4),
                                          oob=scales::squish)
}``