Closed RobTesf closed 1 year ago
Hello!
There is actually a built-in way to plotSignal()
to plot two signals together, with one reflected over the x-axis. Since your data is already split by strand, you can input both files to plotSignal()
as a list()
, with the forward strand signal listed first to be in the positive y-axis. You can also input two different colors to fill
and/or linecolor
to have each strand signal colored differently. Here's an example:
library(plotgardener)
#>
#> Attaching package: 'plotgardener'
#> The following object is masked from 'package:base':
#>
#> c
library(plotgardenerData)
data("IMR90_ChIP_H3K27ac_signal")
data("GM12878_ChIP_H3K27ac_signal")
pageCreate(width = 7.5, height = 2)
region <- pgParams(
chrom = "chr21",
chromstart = 28000000, chromend = 30300000,
assembly = "hg19"
)
plotSignal(data = list(GM12878_ChIP_H3K27ac_signal,
IMR90_ChIP_H3K27ac_signal),
params = region,
x = 0.5, y = 0.25,
linecolor = c("blue", "red"),
fill = c("blue", "red"),
width = 6.5, height = 1.5)
#> signal[signal1]
Created on 2023-07-21 with reprex v2.0.2
I hope this helps!
Best, Nicole
works like a charm.
Thanks a lot for the quick response.
I have a potential bug report though in plotMultiSignal()
. range
argument does not seem to be taken into consideration with this function:
library("plotgardenerData")
data("GM12878_ChIP_CTCF_signal")
data("IMR90_ChIP_CTCF_signal")
data("GM12878_ChIP_H3K27ac_signal")
data("IMR90_ChIP_H3K27ac_signal")
library("RColorBrewer")
## List of multiple signal datasets
signalList <- list(GM12878_ChIP_CTCF_signal, GM12878_ChIP_H3K27ac_signal,
IMR90_ChIP_CTCF_signal, IMR90_ChIP_H3K27ac_signal)
## Create page
pageCreate(width = 6.9, height = 3.5, default.units = "inches")
## Plot multiple signals
multisignal <- plotMultiSignal(signalList, chrom = "chr21",
chromstart = 28150000, chromend = 29150000,
linecolor = c(brewer.pal(n = 9,"YlGnBu")[4],
brewer.pal(n = 9,"YlGnBu")[5],
brewer.pal(n = 9,"YlGnBu")[6],
brewer.pal(n = 9,"YlGnBu")[7]),
label = c("GM12878 CTCF", "GM12878 H3K27ac",
"IMR90 CTCF", "IMR90 H3K27ac"),
assembly = "hg19",
x = 0.2, y = 0.2,
width = 6.5, height = 3,
default.units = "inches",
gapdistance = 0.1)
## Create page
pageCreate(width = 6.9, height = 3.5, default.units = "inches")
## Plot multiple signals
multisignal <- plotMultiSignal(signalList, chrom = "chr21",
chromstart = 28150000, chromend = 29150000,
linecolor = c(brewer.pal(n = 9,"YlGnBu")[4],
brewer.pal(n = 9,"YlGnBu")[5],
brewer.pal(n = 9,"YlGnBu")[6],
brewer.pal(n = 9,"YlGnBu")[7]),
label = c("GM12878 CTCF", "GM12878 H3K27ac",
"IMR90 CTCF", "IMR90 H3K27ac"),
assembly = "hg19",
x = 0.2, y = 0.2,
width = 6.5, height = 3,
default.units = "inches",
gapdistance = 0.1,range=c(0,500))
These 2 commands give the exact same plot...
Ah yes, the range
parameter for plotMultiSignal
is a bit misleading; plotMultiSignal
internally calculates the best range for all the signals and currently overrides any user-defined range. I'll work on clarifying this. Thanks for pointing this out!
Nicole
Hello, I was wondering is there an option to flip the line plots of
plotSignal()
. I have two bigwig tracks of signals from forward and reverse strands and I would like to plot them one on top of the other with the reverse strand signal having upside-down y axis. It's similar to what you propose withfill
argument able to take a "strand" information when reading bed files usingplotRanges()
. I believe the option of angle inviewport()
could do the trick, and I tried to fix it by tweaking your files but have problems finding the accessory functions... Thanks in advance for the time