Plot lines color change in plotAvgProf2 [ChIPseeker]
2
1
Entering edit mode
2.7 years ago
anu014 ▴ 180

Hello Biostars!

I hope you are shining bright!

Today, I'm dealing with a very basic problem that's plotting lines color change. It's very easy in general plot function and ggplot. But in case of a function by ChIPseeker - 'plotAvgProf2', I'm not able to figure how to give arguments as there's not default argument like 'col' or 'colour' in the function :

plotAvgProf2            package:ChIPseeker             R Documentation

plotAvgProf

Description:

plot the profile of peaks that align to flank sequences of TSS

Usage:

plotAvgProf2(peak, weightCol = NULL, TxDb = NULL, upstream = 1000,
downstream = 1000, xlab = "Genomic Region (5'->3')",
ylab = "Read Count Frequency", conf, facet = "none", free_y = TRUE,
verbose = TRUE, ...)

Arguments:

peak: peak file or GRanges object

weightCol: column name of weight

TxDb: TxDb object

upstream: upstream position

downstream: downstream position

xlab: xlab

ylab: ylab

conf: confidence interval

facet: one of 'none', 'row' and 'column'

free_y: if TRUE, y will be scaled by AvgProf

verbose: print message or not



I don't even how to edit the function too :

> plotAvgProf2
function (peak, weightCol = NULL, TxDb = NULL, upstream = 1000,
downstream = 1000, xlab = "Genomic Region (5'->3')", ylab = "Read Count Frequency",
conf, facet = "none", free_y = TRUE, verbose = TRUE, ...)
{
if (verbose) {
cat(">> preparing promoter regions...\t", format(Sys.time(),
"%Y-%m-%d %X"), "\n")
}
promoter <- getPromoters(TxDb = TxDb, upstream = upstream,
downstream = downstream)
if (verbose) {
cat(">> preparing tag matrix...\t\t", format(Sys.time(),
"%Y-%m-%d %X"), "\n")
}
if (is(peak, "list")) {
tagMatrix <- lapply(peak, getTagMatrix, weightCol = weightCol,
windows = promoter)
}
else {
tagMatrix <- getTagMatrix(peak, weightCol, promoter)
}
if (verbose) {
cat(">> plotting figure...\t\t\t", format(Sys.time(),
"%Y-%m-%d %X"), "\n")
}
if (!(missingArg(conf) || is.na(conf))) {
p <- plotAvgProf.internal(tagMatrix, xlim = c(-upstream,
downstream), xlab = xlab, ylab = ylab, conf = conf,
facet = facet, free_y = free_y)
}
else {
p <- plotAvgProf.internal(tagMatrix, xlim = c(-upstream,
downstream), xlab = xlab, ylab = ylab, facet = facet,
free_y = free_y)
}
return(p)
}
<environment: namespace:ChIPseeker>


By default, it gives blue n brown colour for 2 samples . I need to change that. Please help me out. Thank you in advance :)

R ChIP-Seq ChIPseeker • 1.7k views
1
Entering edit mode
2.7 years ago
anu014 ▴ 180

https://github.com/GuangchuangYu/ChIPseeker/issues/89

All the best!

1
Entering edit mode
2.7 years ago
Guangchuang Yu ★ 2.5k

see ?ggplot2::scale_color_manual

0
Entering edit mode

Thank you Guangchuang! I'll try it now. And how the thickness of the line can be changed in the plot? Can we use all the ggplot2 plot styling functions with plotAvgProf2?

0
Entering edit mode

Greetings of the day Guangchuang! I tried the below commands , but it gave me error:

require (ChIPseeker)
require (clusterProfiler)
library(GenomicFeatures)

txdb <- makeTxDbFromGFF("trial.gff3",circ_seqs=character(), organism="Mycobacterium tuberculosis")

list1 <- list(peak2,peak3)

names(list1)[1] <- "RNAP"
names(list1)[2] <- "T"

pdf(file="profile.pdf",width=5,height=5)
par(mar = c(3.5,3.5,1.0,0.5), mgp = c(2,0.65,0), cex = 0.8)
try(plotAvgProf2(list1, TxDb=txdb, upstream=3000, downstream=3000,weightCol="fold_enrichment", xlab="Genomic Region (5'->3')", ylab = "Read Count Frequency", scale_colour_manual(values = c("blue", "green"))))
>> preparing promoter regions...     2018-11-19 02:44:00  IST
>> preparing tag matrix...       2018-11-19 02:44:01  IST
>> plotting figure...            2018-11-19 02:44:28  IST
Error in scale_colour_manual(values = c("blue", "green")) :
could not find function "scale_colour_manual"
dev.off()
null device
1


How should I give 'scale_color_manual' in the command?

0
Entering edit mode

I figured out the error was due to absence of library(ggplot2). Still after adding this. I got this:

>> preparing promoter regions...     2018-11-19 03:12:55  IST
>> preparing tag matrix...       2018-11-19 03:12:55  IST
>> plotting figure...            2018-11-19 03:13:31  IST
Error in t.star[r, ] <- res[[r]] :
number of items to replace is not a multiple of replacement length

1: In is.na(conf) :
is.na() applied to non-(list or vector) of type 'environment'
2: In is.na(conf) :
is.na() applied to non-(list or vector) of type 'environment'
3: In parallel::mclapply(seq_len(RR), fn, mc.cores = ncpus) :
scheduled cores 2, 1 encountered errors in user code, all values of the jobs will be affected