Question: Unable to set colors in plotrt function in xcms package
0
gravatar for Johannes Rainer
4.5 years ago by
Johannes Rainer1.5k
Italy
Johannes Rainer1.5k wrote:

dear All,

I think there is a bug in the plotrt function of xcms: I get an error message after specifying the colors for individual samples in the plotrt. Without specifying the colors using the col argument the function works as expected.

The code:

## xset is a xcmsSet from 3 mzML files; defining the colors:

> FileCols <- brewer.pal(length(sampnames(xset)), "Set1")
> FileCols
[1] "#E41A1C" "#377EB8" "#4DAF4A"

## plotting with these colors:

> plotrt(xset, col=FileCols)
Error in 1:max(col) : NA/NaN argument
In addition: Warning message:
In .local(object, ...) : NAs introduced by coercion

The sessionInfo:

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin14.0.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] grid      parallel  stats     graphics  grDevices utils     datasets
[8] methods   base     

other attached packages:
[1] lattice_0.20-30     xcms_1.42.0         mzR_2.0.0          
[4] Rcpp_0.11.4         ascii_2.1           RColorBrewer_1.1-2
[7] Biobase_2.26.0      BiocGenerics_0.12.1

loaded via a namespace (and not attached):
[1] codetools_0.2-10 compiler_3.1.2   tools_3.1.2   

 

cheers, jo

xcms bug • 705 views
ADD COMMENTlink modified 4.5 years ago • written 4.5 years ago by Johannes Rainer1.5k
Answer: Unable to set colors in plotrt function in xcms package
1
gravatar for Thomas Lin Pedersen
4.5 years ago by
Copenhagen, Denmark
Thomas Lin Pedersen70 wrote:

Hi Johannes

It seems the col argument should take an integer vector defining the grouping of your samples, not an actual vector of colours. So - for instance - if you wanted to give sample 1 and 3 a similar color you would pass in c(1, 2, 1).

 

The good thing is that it is quite easy to extract the underlying data from your xcmsSet object and make your own plot, e.g. based on ggplot2 where you have full control over the aesthetics. The relevant data is stored in object@rt$raw and object@rt$corrected.

Hope this helps - Thomas

ADD COMMENTlink written 4.5 years ago by Thomas Lin Pedersen70

Thanks for your quick reply!

Yes, I also checked the source code and got to that conclusion. I've forked the xcms project on github and modified the code so that it will also allow submission of color definitions other than numeric (hope the maintainer will accept the pull request...).

cheers, jo

ADD REPLYlink written 4.5 years ago by Johannes Rainer1.5k
Answer: Unable to set colors in plotrt function in xcms package
0
gravatar for Johannes Rainer
4.5 years ago by
Johannes Rainer1.5k
Italy
Johannes Rainer1.5k wrote:

Answering myself now ;)

I've added the code to support submission of color definitions other than numeric with the col argument and this has now been included to the xcms package (will be in the developmental branch tomorrow). Thanks to Steffen for including the code that fast!

cheers, jo

ADD COMMENTlink written 4.5 years ago by Johannes Rainer1.5k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 345 users visited in the last hour