sneumann / xcms

This is the git repository matching the Bioconductor package xcms: LC/MS and GC/MS Data Analysis
Other
178 stars 81 forks source link

plot log2-transformed intensity in XIC #594

Open gmhhope opened 2 years ago

gmhhope commented 2 years ago

Hi Johannes,

Is there a way I can plot the log2-transformed intensities instead of absolute intensities? The intensities of some peaks are too dramatic and they masked my important small peaks as shown below. ··· for (i in (1:length(mz.v))) { chr_raw <- chromatogram(raw_data, mz = c(mz.v[i]-ppm2mz_diff(mz.v[i],ppm), mz.v[i]+ppm2mz_diff(mz.v[i],ppm)), rt = c(0,300)) plot(chr_raw, col = group_colors[chr_raw$sample_group], xlab="", ylim = c(0,1000000)) } ···

Figure with ylim = = c(0,1000000)

Screen Shot 2022-01-03 at 7 48 28 PM

Figure without ylim

Screen Shot 2022-01-03 at 7 50 48 PM

Thanks very much!

Best, Minghao Gong

jorainer commented 2 years ago

There is no dedicated function available yet to transform intensity values - but it's definitely an important issue. I will think of a (flexible) solution.

jorainer commented 2 years ago

I've now implemented a transformIntensity method for chromatographic data in the MSnbase and xcms packages. That function allows you to transform intensity values (along with peak data if you have an XChromatogram object) using any function passed with parameter FUN.

In your case you could then call

chr_log2 <- transformIntensity(chr_raw, log2)

to log2 transform the intensity values and then plot this data.

This functions are available in the current developmental versions of MSnbase and xcms. To install you would need to install the bleeding edge versions from github:

BiocManager::install("lgatto/MSnbase")
BiocManager::install("sneumann/xcms", ref = "jomain")

Could be that you need to update/install also other packages along the way... I hope that fixes your issue.

gmhhope commented 2 years ago

Hi Johannes,

Thanks very much!

I will check in it and let you know how it goes!

Best regards, Minghao Gong

gmhhope commented 2 years ago

Hi Johannes,

When I tried to do BiocManager::install("lgatto/MSnbase") to update the MSnbase. I got the following error, do you have any suggestion how to bypass this?

Error: package ‘ProtGenerics’ 1.26.0 was found, but >= 1.27.2 is required by ‘MSnbase’
In addition: Warning message:
In fun(libname, pkgname) :
  mzR has been built against a different Rcpp version (1.0.7)
than is installed on your system (1.0.8). This might lead to errors
when loading mzR. If you encounter such issues, please send a report,
including the output of sessionInfo() to the Bioc support forum at 
https://support.bioconductor.org/. For details see also
https://github.com/sneumann/mzR/wiki/mzR-Rcpp-compiler-linker-issue.
Execution halted
ERROR: lazy loading failed for package ‘MSnbase’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/MSnbase’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/MSnbase’
Warning message:
In i.p(...) :
  installation of package ‘/var/folders/vw/wq572pm129ddch9_12s00kw1glkwmw/T//Rtmpucy13P/fileddd649cab26b/MSnbase_2.21.4.tar.gz’ had non-zero exit status
stanstrup commented 2 years ago

Do BiocManager::install("RforMassSpectrometry/ProtGenerics") first and try again.

jorainer commented 2 years ago

Thanks @stanstrup , yes, sorry for that, but switching to the bleeding edge devel versions of the packages is not too simple.

gmhhope commented 2 years ago

Thanks @stanstrup , yes, sorry for that, but switching to the bleeding edge devel versions of the packages is not too simple.

I did drive into issues when I try to update the bleeding edge devel version. To avoid issues for other processing, I will drop the test for this function for a moment. But thanks very much for making such wonderful function happen!

Best, Minghao Gong