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

make an option to plot different datasets by different colors #180

Open
kkupkova opened this issue Jan 14, 2022 · 3 comments
Open

make an option to plot different datasets by different colors #180

kkupkova opened this issue Jan 14, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@kkupkova
Copy link
Contributor

Some functions currently don't offer the option to plot different datasets by different colors (plotFeatureDist, plotQTHist) and are written in a way that it would be impossible to add that option as another layer to the ggplot object.

@kkupkova kkupkova added the enhancement New feature or request label Jan 14, 2022
@rrashford
Copy link

Hi!

I am interested in this issue. Is there a way to change the colors for plotting on these three functions?
plotChromBins
plotExpectedPartitions
plotPartitions

All the best,

@kkupkova
Copy link
Contributor Author

kkupkova commented Jul 2, 2022

Hi! The output of the plot function is always ggplot object, so you can always add another layer or change the color setting. I am giving here examples for the three functions you are interested in - for single region set or multiple region sets:

# upload queries
# single query
queryFile = system.file("extdata", "vistaEnhancers.bed.gz", package="GenomicDistributions")
query = rtracklayer::import(queryFile)

# query list
query2 = GenomicRanges::shift(query, 1e6)
queryList = GRangesList(vistaEnhancers=query, shifted=query2)

# 1) single region set - change color to red
# chromosome distribution
chrombins = calcChromBinsRef(query, "hg19")
p = plotChromBins(chrombins)
p$layers[[1]]$aes_params$fill =  'red'
p

# partition overlap
part = calcPartitionsRef(query, "hg19")
p = plotPartitions(part)
p$layers[[1]]$aes_params$fill =  'red'
p

# expected paritions
ePart = calcExpectedPartitionsRef(query, "hg19")
p = plotExpectedPartitions(ePart)
p$layers[[1]]$aes_params$fill =  'red'
p

# 2) multiple region sets - change color to red and blue
chrombins = calcChromBinsRef(queryList, "hg19")
plotChromBins(chrombins) + 
  scale_fill_manual(values = c("red", "blue")) +
  scale_color_manual(values = c("red", "blue"))

# partition overlap
part = calcPartitionsRef(queryList, "hg19")
plotPartitions(part)+ 
  scale_fill_manual(values = c("red", "blue")) 


# expected paritions
ePart = calcExpectedPartitionsRef(queryList, "hg19")
plotExpectedPartitions(ePart)+ 
  scale_fill_manual(values = c("red", "blue")) 

These examples are applicable to all of the other plotting functions. Hope this helps!

@rrashford
Copy link

Yes! This was super helpful. Thank you!

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

No branches or pull requests

2 participants