griffithlab / GenVisR

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

cnSpec() forces the order of samples #337

Closed zlskidmore closed 5 years ago

zlskidmore commented 6 years ago

We should give the end user more control over the ordering of samples in the cnSpec() function. Currently the only way to control the order of facets in ggplot2 is by the order of levels for that data. The typical way to change the ordering is with the function factor() however currently we enforce an alphanumeric order here: https://github.com/griffithlab/GenVisR/blob/0a04cba8acb14cec15048cd49a9043fd60bb2efb/R/cnSpec.R#L133

Original request from here: https://support.bioconductor.org/p/109523/

Dagsbio commented 5 years ago

Hi, is there maybe a workaround for this? I've tried adding a ggplot Layer but can't make it.

Thanks

zlskidmore commented 5 years ago

if your sample column is a factor genvisr will instead use that ordering. That's the only work around currently, using the example dataframe loaded with genvisr:

# original plot
cnSpec(LucCNseg, genome="hg19")

# new order
LucCNseg$sample <- factor(LucCNseg$sample, levels=rev(levels(LucCNseg$sample)))
cnSpec(LucCNseg, genome="hg19")
Dagsbio commented 5 years ago

Right, that works, thank you!