Unable to set colors in plotrt function in xcms package
2
0
Entering edit mode
Johannes Rainer ★ 1.9k
@johannes-rainer-6987
Last seen 5 days ago
Italy

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 • 776 views
ADD COMMENT
1
Entering edit mode
@thomas-lin-pedersen-5941
Last seen 5.3 years ago
Copenhagen, Denmark

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 COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode
Johannes Rainer ★ 1.9k
@johannes-rainer-6987
Last seen 5 days ago
Italy

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 COMMENT

Login before adding your answer.

Traffic: 451 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6