From e534778129bb2b303e3bc782443e805aa684aa95 Mon Sep 17 00:00:00 2001 From: "s.neumann" Date: Wed, 9 Aug 2017 09:24:08 +0000 Subject: [PATCH] Squashed commit of the following: commit d3f47ca69474af4913ad8d1cc0cfe9420011ddda Author: jotsetung Date: Wed Aug 9 08:40:08 2017 +0200 Add BiocStyle package to xcms-direct-injection vignette commit 0aba7270a9fdeae76c8ad409c6cfe702cf3bbb56 Author: jotsetung Date: Wed Aug 9 08:18:27 2017 +0200 Replace xcmsDirect.Rnw vignette with rmarkdown version commit 31e1e389529913bcb06e8a5ab88328557681617b Author: jotsetung Date: Tue Aug 8 09:23:17 2017 +0200 Add calibrate,XCMSnExp method - Add calibrate,XCMSnExp method (issue #199). - Add related unit tests and documentation. - Add a warning if peaks are not sorted by mz in calibrate,xcmsSet (issue #200). commit 02cfd24c757557f3c32908390af9cec342c92847 Author: jotsetung Date: Fri Aug 4 15:24:51 2017 +0200 Update the plotChromPeakDensity function - plotChromPeakDensity allows now to either simulate correspondence based on provided settings, or to visualize correspondence results. - Fixed problems in plotChromPeakDensity function when cex, bg or other point-specific parameters were passed. - Increase the argument n for the density function in the peak density correspondence analysis by 2. commit 3814110b76afa62458a012ce4f92787ab6bbb0c6 Author: jotsetung Date: Fri Aug 4 13:17:30 2017 +0200 Add arguments mz and rt to featureDefinitions - Add arguments mz and rt to featureDefinitions,XCMSnExp that enable to extract features for the specified rt / m/z range. - Add related documentation and unit tests. commit 84cfdc2071425efb8cbe3dd1d3ce47792c4abdd2 Author: jotsetung Date: Fri Aug 4 11:20:00 2017 +0200 Add parameter main to plotChromPeakDensity function commit d113ff3826dd6e9e9b89e050f3023f6ed4f5b0bf Author: jotsetung Date: Fri Aug 4 09:14:06 2017 +0200 Clean xcmsDirect.Rnw vignette commit d38dfa0536b37dd605f7fb374fa4163fa09951bf Author: jotsetung Date: Fri Jul 28 19:08:02 2017 +0200 Fix issue #194 - Ensure raw data objects are subsetted correctly if scanrange is provided. - Ensure that the profile matrices are correctly expanded to match their number of rows. commit 03784d5fe6f2b684c5793308115938135969c8de Author: jotsetung Date: Fri Jul 28 08:30:22 2017 +0200 Tentative fix for issue #196 - In obiwarp for OnDiskMSnExp objects: remove the check that ensures that the profile matrices of the files to be aligned have to have the same dimension. That would require all files to have the same number of scans, which does not have to be the case. commit fea13e212d96c8aaa864eb078b6b8c4f15fc7ace Author: jotsetung Date: Thu Jul 27 08:17:13 2017 +0200 Bump version and update NEWS commit fc15e26c6ad1d9ea7d2295b974d7bd1401cded52 Merge: 515b008 27e525c Author: jotsetung Date: Thu Jul 27 08:11:06 2017 +0200 Merge branch 'devel' of https://github.com/sneumann/xcms into devel commit 515b008104858809cd952866129d32da86446698 Author: jotsetung Date: Thu Jul 27 08:05:15 2017 +0200 Export phenoDataFromPaths function (issue #195) - Export the phenoDataFromPaths function to enable the old way to define the pheno data from the folder structure in which the files are located. - Add related documentation and unit test. commit 27e525c5c76407e97a93ef997e7d22fbfd18cf4d Merge: 1a3144a 4c22c3c Author: Steffen Neumann Date: Fri Jul 21 21:07:52 2017 +0200 Merge branch 'biocdevel' into devel commit 1a3144aafc7f8a99575398d5c7d8d3ff0ae6870f Author: jotsetung Date: Fri Jul 21 06:55:18 2017 +0200 Documentation tidying. commit f7825ada4f743ff83ea71669b888d7b1c42d47fd Author: jotsetung Date: Fri Jul 21 06:39:29 2017 +0200 Re-enable sleep parameter in findPeaks.matchedFilter - Add sleep parameter to do_findChromPeaks_matchedFilter. - Re-enable sleep parameter in findChromPeaks.matchedFilter. - Update relevant documentation. commit 5beacd4db53f7caa65ad6b4dea135ebf5be37c83 Author: jotsetung Date: Tue Jul 18 06:58:01 2017 +0200 Re-enable the sleep parameter in centWave - Re-add plotting functionality to the do_findChromPeaks_centWave function. Add the parameter sleep. commit 46079088821e45f4ed9e8d933de5af40af259c94 Author: jotsetung Date: Fri Jul 14 09:30:23 2017 +0200 Fix unit test to work with recent change in MSnbase commit 9c18189766d59ab91a51f8e840a54b2832ea1259 Author: jotsetung Date: Wed Jul 12 16:06:14 2017 +0200 Some example performance tuning commit 741073f6f56aa8ee29ca370b751827b5844ebe1a Author: jotsetung Date: Wed Jul 12 15:05:19 2017 +0200 Fix bracket errors commit 80a47b4d43e5eedadd98446f0392d6a6b6b36dc4 Author: jotsetung Date: Wed Jul 12 15:01:21 2017 +0200 Fix parallel processing for Windows systems - Fix parallel processing in unit tests and vignettes to use SnowParam on non-unix systems. commit 7ff49c94929461100da1b24b5bc40073d381d1cc Author: jotsetung Date: Wed Jul 12 10:36:42 2017 +0200 Small fixes to the adjustDriftWithModel function commit 02ebe57154eadf18d22745d5f7ab49fb849d5b34 Author: jotsetung Date: Wed Jul 12 07:56:51 2017 +0200 Add plotChromPeakImage function (issue #154) - Add the plotChromPeakImage function. - Add related unit tests, documentation and update vignette. - Add a source file with some first (unexported) data normalization functions. commit 9609d4dda044bf8cd10aa80632fabb0096131576 Author: jotsetung Date: Tue Jul 11 13:03:42 2017 +0200 Add plotChromPeaks function (issue #154) commit 7aa5ef0add5391e10b237f33bc36fde934b595f0 Author: jotsetung Date: Mon Jul 10 11:07:54 2017 +0200 Read polarity information from mzXML files - Read also polarity information from mzXML files (issue #192). - Don't import aggregationFun and productMz from MSnbase. commit 8d829a2da4b88a5113269ffb579e4d13aa6cb8f4 Author: jotsetung Date: Mon Jul 10 10:42:25 2017 +0200 Import aggregationFun and productMz as functions - aggregationFun and productMz were changed from methods to functions in MSnbase - import these functions. commit 587b2d14e55ec553c3d2c01b35c3992d0599436e Author: jotsetung Date: Wed Jun 21 15:07:48 2017 +0200 Import all Chromatogram functionality from MSnbase - Import all required functions and classes related to chromatogram data from MSnbase. - Update all examples, unit tests and vignettes to use the new methods. - Deprecated extractChromatograms and plotChromatogram. - Fix an issue that caused an uninformative error message when peak detection was performed on an MS2 only OnDiskMSnExp (issue #190). - Add argument msLevel to the findChromPeaks methods allowing to perform chromatographic peak detection on MS > 1 (enabling SWATH issue #190). commit b138398ba618c07368638f1be80c675dfec15cba Author: jotsetung Date: Tue Jun 20 12:33:43 2017 +0200 Import Chromatogram class and methods - Import Chromatogram object. - Deprecate extractChromatograms. - import chromatogram,OnDiskMSnExp. commit 1eba1d17b462791f890e1d04282fbd0257259ecd Merge: 1b1e42a 710a8f9 Author: jotsetung Date: Fri Jun 16 13:18:19 2017 +0200 Merge branch 'devel' into xcms3 commit 1b1e42a1d39efeabba6e9acf52bf9b74c33d6937 Author: jotsetung Date: Fri Jun 16 13:16:42 2017 +0200 Remove Chromatogram class commit 710a8f9d44f3e330fe0072bf02cc9ac8548bf120 Merge: 7ef7059 056dd82 Author: Steffen Neumann Date: Fri Jun 16 07:25:02 2017 +0200 Merge branch 'biocdevel' into devel commit bcac6ab7afad578085d3a83a8a911812c35cf79a Author: jotsetung Date: Thu Jun 15 10:19:01 2017 +0200 Tune unit tests and vignettes #187 commit 7ef70598754cffc9e896ddb3358f62471e0d16cb Author: jotsetung Date: Tue Jun 13 16:32:36 2017 +0200 Fix issue #188 - For files with unknown file extension determine the file type from its content. - Add related unit tests. commit a245c74557fa2937b94637dd9ec36183bc62491d Author: jotsetung Date: Mon Jun 12 16:17:11 2017 +0200 Tune some unit tests and examples - Related to issue #187: tune some unit tests and examples. commit 8e8db555541e71d929e06e8afb5e2738f0201147 Merge: 3d03ef5 82fe82b Author: Steffen Neumann Date: Tue Jun 6 12:42:12 2017 +0200 Merge branch 'biocdevel' into devel commit 3d03ef5433aca18593e4fc4ee126ca41dbf753a3 Merge: bafb6de 8c1220e Author: Johannes Rainer Date: Tue Jun 6 10:54:35 2017 +0200 Merge pull request #185 from sneumann/issue184 Fix issue #184 commit 8c1220eaf7f866572e726b11baaa7672c514c237 Author: jotsetung Date: Mon Jun 5 17:26:53 2017 +0200 Fix issue #184 - Add parameter sleep to the do_groupChromPeaks_density function to ensure backward compatibility with the old group.density code. commit bafb6de6bb3939a45b108865eac69ddaef7c4a51 Author: jotsetung Date: Wed May 31 13:04:34 2017 +0200 Fix some more typos and tidy roxygen text commit 5249622a585b8bea916c14a0683a158dd7210a2f Merge: ffc9e39 54cc415 Author: jotsetung Date: Wed May 31 12:45:50 2017 +0200 Merge branch 'devel' into xcms3 commit ffc9e39dd8570fa51e9c4abd1b99864bdd25b7fd Author: jotsetung Date: Wed May 31 12:42:36 2017 +0200 Fix for issue #181 - issue #181: isCentroided returns NA is there are too peaks in a spectrum. The methods in xcms (findChromPeaks,OnDiskMSnExp,CentWaveParam) check first whether the first spectrum is centroided, if an NA is returned isCentroided is called on all spectra and based on that the function determines whether the data set is centroided. commit 54cc4154926ec6123b237ce3a0433c1fef13e5e7 Merge: aabdf5c f9bbe42 Author: Johannes Rainer Date: Wed May 31 10:53:52 2017 +0200 Merge pull request #183 from stanstrup/patch-6 typos commit f9bbe4287ca6f1560e33fccaad63842b58d57dfd Author: Jan Stanstrup Date: Wed May 31 10:51:34 2017 +0200 typos commit aabdf5c29daddd60aae2c7b12512dcf1f6d5bc1c Merge: 4dfbc01 13f69c8 Author: Steffen Neumann Date: Sun May 28 18:56:31 2017 +0200 Merge branch 'biocdevel' into devel commit 4dfbc01c1ec656fed8e0d3a4e262193f1061ebb3 Author: jotsetung Date: Fri May 26 11:52:55 2017 +0200 Fix issue #180 commit 8dfccd382b73c3f772b4a80b7d2fbe38b57c0a96 Author: jotsetung Date: Fri May 26 08:56:17 2017 +0200 Update NEWS. commit d290cbeb8d57a69305f7f7315135fa26f6eb80b5 Merge: 56c43dd d2d4b7a Author: jotsetung Date: Thu May 25 17:17:59 2017 +0200 Merge branch 'devel' into xcms3 commit d2d4b7a2a18a9a1620eaa52e94dc81edb2c939e9 Merge: f11aac4 d9baa6c Author: Johannes Rainer Date: Thu May 25 16:31:59 2017 +0200 Merge pull request #178 from stanstrup/patch-4 scanrange was collapsed when the adjusted range was reported. commit d9baa6ca364f4dd197a9eedd361869cf0787dbc3 Author: Jan Stanstrup Date: Mon May 22 14:01:47 2017 +0200 scanrange was collapsed when the adjusted range was reported. ```r > scanrange=c(1,1400) > message("Provided scanrange was adjusted to ", scanrange) Provided scanrange was adjusted to 11400 > > > message("Provided scanrange was adjusted to ", scanrange[1]," - ", scanrange[2]) Provided scanrange was adjusted to 1 - 1400 > ``` commit 56c43ddfd7eece4fe58f1f81da66714bf23e32ef Author: jotsetung Date: Fri May 19 12:20:29 2017 +0200 Fix for issue #173 - Stitching of mzML files did not fill in mz and intensity values for the last spectrum. commit 95a8deadbc29b7433678cd35b05690961c99dd6c Author: jotsetung Date: Thu May 18 15:36:54 2017 +0200 Fix for issue #175 - Disable original xcms-preprocessing vignette. commit 36535df5d03137a1d3db62fbf7a9f85c7fdaf8a9 Author: jotsetung Date: Mon May 15 09:08:31 2017 +0200 Add extractMsData method (issue #120) - Add extractMsData to extract MS data (mz, rt, intensity duples) as a data.frame (related to issue #120). - Add related unit tests and documentation. commit b273693c627451f470d1c5a91c435f384ce9cdf7 Author: jotsetung Date: Fri May 5 13:21:14 2017 +0200 Fix for bug introduced into plotChromPeakDensity commit ad6aa2bf4bec129147c1407d0325f531dcf1fcb0 Author: jotsetung Date: Fri May 5 13:03:00 2017 +0200 Add Jan Stanstrup's fix also to the plotChromPeakDensity function commit 906be43e92aee5ac54b97ee795ada7848cbae5c5 Author: jotsetung Date: Fri May 5 13:00:30 2017 +0200 Update news. commit 11ed73c97b5c1ea28354172da7f639eff85bae38 Merge: e90b74e f11aac4 Author: jotsetung Date: Fri May 5 12:59:04 2017 +0200 Merge branch 'devel' into xcms3 commit f11aac4020319d991b845154e492f1031f946888 Author: jotsetung Date: Fri May 5 12:43:06 2017 +0200 Fix problem with merge from Jan Stanstrup - Remove definitions of argument n in density functions other than in do_groupChromPeaks_density: fixes errors in the vignette. - Fix issue #161. commit 9129650cdba019bcacba62441d2623e50168a498 Merge: 77c51a4 60ff595 Author: Johannes Rainer Date: Fri May 5 11:14:26 2017 +0200 Merge pull request #162 from stanstrup/patch-5 fixes for #161: increase parameter `n` in `density` function calls for *peak density* correspondence. commit e90b74e3c30bdf3860b475b549db6fdb158ecd60 Author: jotsetung Date: Fri May 5 11:10:57 2017 +0200 Remove un-needed functions from functions-XCMSnExp.R commit 77c51a444c14b962c54b3ca6c0eabc7dd3f7c2f8 Merge: 14e701c cf3a862 Author: Steffen Neumann Date: Fri May 5 09:49:28 2017 +0200 Merge branch 'biocdevel' into devel commit 58e35e588c0f4654f013f06933356b0d232f1f99 Author: jotsetung Date: Fri May 5 09:41:03 2017 +0200 Add plotChromPeakDensity function (issue #171) - Add the plotChromPeakDensity function to evaluate peak density correspondence settings. - Add related unit tests and documentation. commit 9de2927231f6c92fe600381ec5f3758093dd642d Author: jotsetung Date: Tue May 2 09:32:25 2017 +0200 Add new clean,Chromatogram method - Add new clean,Chromatogram method. - Add related unit tests and documentation. commit f7719b8d4c8a04cc2bc349802c309441e3fee382 Author: jotsetung Date: Thu Apr 27 22:18:33 2017 +0200 Fixes to the extractChromatograms method - Ensure that the returned lists per rt/mz range have the same lengths than there are files. - Return a Chromatogram object of length equal to the number of scans within the specified retention time range, even if no measurement is available for the provided mz range (report NA_real_). - Add parameter missing to the extractChromatograms method to allow specifying the intensity value to be used if no signal was measured for a rt in the specified mz range. commit 20c7e9e048d8117733f8af7309307308262ee563 Author: jotsetung Date: Wed Apr 26 08:12:47 2017 +0200 extractChromatograms extracts multiple ranges - extractChromatograms extracts multiple ranges to enable efficient chromatogram extraction without re-reading the raw data (issue #168). - Add corresponding unit tests and documentation. - Fix in plotChromatogram to avoid warnings if the number of measured data values differs between files (issue #167). - Extend new_functionality vignette. - Disable parallel processing in preprocessing vignette. commit 77b0396c54e2afe61de1df09271ec1ce427781e3 Author: jotsetung Date: Fri Apr 21 15:25:27 2017 +0200 Fix bug in plotChromatogram commit 612cecfc868a55b94c43cf01d16b15ea6c56418c Author: jotsetung Date: Fri Apr 21 14:27:48 2017 +0200 Ensure plotChromatogram doesn't break if no data available commit af6eea822cb9edb1d9d979289617b022b6947584 Author: jotsetung Date: Fri Apr 21 09:20:35 2017 +0200 Add plotChromatogram and highlightChromPeaks functions - Add plotChromatogram and highlightChromPeaks functions (issue #167). - Add documentation. commit d045d708e1802f81e54a307220d19e0b18253a61 Author: jotsetung Date: Wed Apr 19 09:57:22 2017 +0200 Fix validation method for CentWaveParam if roiList is provided commit 14e701ce3e3c0f271bb7f6f38a678f132d007442 Merge: f775cbb 84a5375 Author: Steffen Neumann Date: Fri Apr 14 19:20:26 2017 +0200 Merge branch 'biocdevel' into devel commit f775cbb7336e160ff7157d5e897c5cd1a0e93d8c Merge: aa9f1d3 30bb9b2 Author: jotsetung Date: Thu Apr 13 18:59:42 2017 +0200 Merge branch 'xcms3' into devel commit 30bb9b270ff90a4a54b8e752f3abf8dd609ee811 Author: jotsetung Date: Thu Apr 13 18:57:46 2017 +0200 Update date commit 9d507248152612eabc049cd887f838aa525545d9 Author: jotsetung Date: Thu Apr 13 13:22:42 2017 +0200 Avoid fillPeaks using deprecated API (issue #163) - Implement .getPeaks_new that does no longer depend on deprecated profFun calls. - Change getPeaks to use by default the new .getPeaks_new function (fixes fillPeaks issue #163). - Add corresponding unit tests. commit 60ff5957cf9ef6a7729710eb2fdb823209fa8d62 Author: Jan Stanstrup Date: Tue Apr 11 11:01:47 2017 +0200 additional fixes for #160 commit 959004a09888b236111bc0ef5a9f829a5558c174 Author: Jan Stanstrup Date: Tue Apr 11 10:57:25 2017 +0200 devel patch for # 160 commit 0b26f47f3bb48080c5691af82631e176e6312018 Author: jotsetung Date: Mon Apr 10 08:24:36 2017 +0200 Fix possible memory problem in obiwarp (issue #159) - Fix issue #159. - Add example on how to inspect raw peak data in the new user interface (issue #155). commit a7cc281eae4013c691afacccaf010596756266b6 Author: jotsetung Date: Fri Apr 7 08:06:22 2017 +0200 Update documentation of fillPeaks.chrom - Update the documentation of fillPeaks.chrom. - Display message if nSlaves is used suggesting to use BPPARAM instead (issue #158). commit 00786dab2f8d73ad9fdf45f17da28d8f024fe89c Author: jotsetung Date: Thu Apr 6 08:04:07 2017 +0200 Clean up imports and dependencies - Import specific functions from Biobase instead of the full package. - Move packages from Depends to Imports. commit e4a970e93d8a1c14baf920684bfae5e2f9ea91cd Author: jotsetung Date: Wed Apr 5 06:29:26 2017 +0200 Add parameters mz, rt, ppm and type to chromPeaks (issue #156) - Add parameters mz, rt, ppm and type to the chromPeaks method to enable extracting chromatographic peaks from the specified range(s). - Add related documentation and unit tests. - Documentation tidying. commit 7fcc690bbc484805528151e26434cd806d244ce4 Author: jotsetung Date: Tue Apr 4 16:56:34 2017 +0200 Add parameter "filled" to featureValues - Add parameter filled to the featureValues,XCMSnExp method (issue #157). - Add related unit tests and documentation. commit aa9f1d3e5241cc22c7ade7165c168bdfb6399e8d Merge: 828883b ecbe9a7 Author: Steffen Neumann Date: Fri Mar 31 13:58:31 2017 +0200 Merge branch 'biocdevel' into devel commit 828883b412f7973f10eacbd58eac2744500ecb13 Author: jotsetung Date: Fri Mar 31 07:50:44 2017 +0200 Updates to the vignette commit cbe41fac512d7ed267b3d1a36bccb023fe776615 Author: jotsetung Date: Thu Mar 30 13:03:59 2017 +0200 Add the plotAdjustedRtime function (issue #141) - Add the plotAdjustedRtime function to visualize alignment results (issue #141) - Add corresponding documentation, unit tests and examples. - Code tidying. - Include plotAdjustedRtime to vignette. commit 592ecdc097dfa72fc92027df46133144d387394b Author: jotsetung Date: Thu Mar 30 09:02:12 2017 +0200 Support predefined peak group matrix for peak groups alignment - Support peak groups-based alignment using a pre-defined peak groups matrix (issue #153). - Add related unit tests and update documentation. commit 985c051ebdd6a7c7f9fe86c19b0616e32458e2c1 Author: jotsetung Date: Wed Mar 29 22:01:07 2017 +0200 Add peakGroupsMatrix slot to PeakGroupsParam class - Add peakGroupsMatrix slot to the PeakGroupsParam class (issue #153). - Add related unit test and update documentation. commit 2ec98ddfef91ebaf5e9f10d51cc44b94647e4dbb Author: jotsetung Date: Wed Mar 29 14:38:15 2017 +0200 Remove private 'isSeizmo' massifquant function. - Remove the private isSeizmo function from massifquant's C++ code (issue #149). commit 0b97c0d38ab8a874a25ce260adbd5c0631898a9b Author: jotsetung Date: Tue Mar 21 09:53:00 2017 +0100 Add adjustRtimePeakGroups function (issue #147) - Add adjustRtimePeakGroups function for XCMSnExp that returns the peak groups that would be used for a given PeakGroupsParam parameter object. - Add related documentation and unit tests. commit 59f1f4940517517f5b3aa324d1ce55ee2c45541a Author: jotsetung Date: Mon Mar 20 17:23:16 2017 +0100 Use feature IDs as rownames in featureValues and featureDefinitions - Add arbitrary feature IDs as rownames to the featureDefinitions DataFrame and use these also for the matrix returned by featureValues (issue #148). - Add related documentation and unit tests. commit 6b52f86e267846e637411fbaddc5e6271230ef81 Author: jotsetung Date: Fri Mar 17 16:25:03 2017 +0100 Add filterRt,Chromatogram method - Add a filterRt,Chromatogram method (issue #142). - Add related unit tests and documentation. commit 0e0a9909d3f684a923c4454b4e64d2dc9a8d8aad Author: jotsetung Date: Fri Mar 17 15:21:13 2017 +0100 Ensure correct ordering of values in Chromatogram constructor o Order intensity and retention time values by retention time if not increasingly ordered in the Chromatogram constructor (issue #145). commit d2f3d141558585e5df094d64876b84f1a8749666 Author: jotsetung Date: Fri Mar 17 08:06:52 2017 +0100 Change order of alignment and correspondence in XCMSnExp,show commit f8148d567b9e2f406755f27149334a103f0b23b4 Author: jotsetung Date: Wed Mar 15 16:22:03 2017 +0100 Fix unordered adjusted retention times in peakGroups o Fix adjustRtime,XCMSnExp,PeakGroupsParam to return for some data adjusted retention times that are not in the same order than raw retention times (issue #146). commit c697bfd54397f856207769ce28a7b75794402379 Author: jotsetung Date: Wed Mar 15 09:15:54 2017 +0100 Ensure adjusted and raw retention times to be in the same order o For adjustRtime,XCMSnExp,PeakGroupParam ensure that adjusted retention times are in the same order than the raw retention times (issue #146). o Show warning if adjusted retention times have to be re-adjusted accordingly. o Show warning if adjusted retention times are not ordered. commit 2b66b28e3905618f7543a6b4b44176ca6bbebf6d Merge: b4c4885 dfe23f3 Author: jotsetung Date: Tue Mar 14 15:53:49 2017 +0100 Merge branch 'devel' into xcms3 commit b4c48850e6976bc599fc02bb5d224bd69ae370b6 Author: jotsetung Date: Tue Mar 14 15:52:07 2017 +0100 Show warning if order of adjusted retention time is not increasing o Show a warning message if the adjusted retention times for a file are not ordered increasingly (issue #146) commit dfe23f315235d0ac965b712de2cd995f54204ec0 Merge: ed89456 215409c Author: Steffen Neumann Date: Fri Mar 10 23:09:00 2017 +0100 Merge branch 'biocdevel' into devel commit e8dbb4c094b0cbaa6a962320047f941f52474207 Author: jotsetung Date: Fri Mar 10 22:02:31 2017 +0100 Avoid multiple/nested parallel processing - Avoid multiple/nested parallel processing calls (issue #144). - Documentation update with newer roxygen2 package. commit ed8945662d82612911bcdbf4be3333ea750d1ef6 Author: jotsetung Date: Fri Mar 10 11:12:53 2017 +0100 Change default backend for mzML files to pwiz (issue #143) commit cf6b1bca8d966a9bc2ffc34d68bfedb76c4eeb93 Author: jotsetung Date: Thu Mar 9 17:04:16 2017 +0100 Remove debug centWave version debug message commit e9f39ecd6540aae7ba4a438d9ca8b26a1e8e80ff Author: jotsetung Date: Wed Mar 8 08:44:30 2017 +0100 Extend new_functionality vignette. commit 572f2ebe0d840929dc4db7fb671f9a54016f7861 Author: jotsetung Date: Tue Mar 7 12:51:15 2017 +0100 Add fillChromPeaks for matchedFilter peak detection o Add support for matchedFilter identified peak in fillChromPeaks,XCMSnExp (issue #130). o Add related documentation and unit tests. commit 6af52f4458663c40fba939044ce5f24c9c8de49c Author: jotsetung Date: Mon Mar 6 14:35:01 2017 +0100 Remove commented old matchedFilter test functions. commit e899b923086b8c540f26a0b1fdb468eb0cd701a3 Author: jotsetung Date: Mon Mar 6 13:43:58 2017 +0100 Ensure XCMSnExp compatibility for single spectrum MS data o Check XCMSnExp on single spectrum direct injection MS data (issue #106). o Add related unit tests. commit 5c6454c1f53da31e898c393a3181465229726e8a Author: jotsetung Date: Mon Mar 6 12:27:36 2017 +0100 Support peak filling for direct infusion data o Add support for MSW identified peaks of single spectra, direct infusion data in fillChromPeaks,XCMSnExp. o Add documentation and related unit tests. commit 889caf0f3ba0188646868d493ee0ba6dc3d9d9bb Author: jotsetung Date: Fri Mar 3 13:58:52 2017 +0100 Extend show method for XCMSnExp commit c9c061fd76e883d33431830a4277d721678af060 Author: jotsetung Date: Fri Mar 3 13:36:52 2017 +0100 Fix expand.rt and expand.mz in fillPeaks (issue #139) commit e51387f7cc7ec952ad258b4b9bd6d46897e582e3 Author: jotsetung Date: Fri Mar 3 13:09:54 2017 +0100 Add featureValues method for XCMSnExp o Add featureValues method for XCMSnExp (issue #131). o Add related unit tests and documentations. commit f7c0547dc6b422d8980b159710a56e4debc04be5 Author: jotsetung Date: Fri Mar 3 12:26:31 2017 +0100 Add dropFilledChromPeaks method o Add dropFilledChromPeaks method (issue #140). o Add related documentation and unit tests. commit e48e977a2e50943e8d41d011515e985362014768 Author: jotsetung Date: Fri Mar 3 10:41:43 2017 +0100 Add @filled slot for XCMSnExp to xcmsSet conversion commit 083fd4b2594ae8e5703ca04ca527ff6a12453fa4 Author: jotsetung Date: Fri Mar 3 10:35:40 2017 +0100 Add fillChromPeaks method and FillChromPeaksParam class o Add fillChromPeaks method and FillChromPeaksParam class. o Add related unit tests and documentation. commit b1b430239a2c5e4e7dda3777e442535f474f5ead Author: jotsetung Date: Thu Mar 2 13:12:28 2017 +0100 o Remove debug messages from xcmsSet. commit d469000b45403204e8796dd1de0dd07fabf7e32c Author: jotsetung Date: Wed Mar 1 15:26:33 2017 +0100 Add modified centWave function and various fixes o Add modified centWave function that integrates peak intensity using only signal within the peak area (issue #136). o Fix error in findChromPeaks if no peaks were found (issue #137). o Fix for failing unit test checking break definition functions (issue #118). commit c821b33adea47101f8e4044ddc3e66b11764665f Merge: 8e44a7b e4b4f89 Author: jotsetung Date: Mon Feb 27 22:11:31 2017 +0100 Merge branch 'devel' into xcms3 commit 8e44a7bb32b532da9fc86c07a7676c1223a6acd5 Author: jotsetung Date: Mon Feb 27 18:47:34 2017 +0100 Update NEWS commit 2d670e210408e778cd896553632e0e9b3969b0ac Author: jotsetung Date: Sun Feb 26 22:12:49 2017 +0100 Fix for issues #118 #133 #134 o Disable part of failing unit test for issue #118 - try to reproduce on a windows build machine o issue #134: show information message if no files are provided showing the directory in which files are listed and the number of found files. o issue #133: don't re-index samlples if no peaks were identified. commit e4b4f8951ae599f3764d29372c23d3dbcc64cd57 Merge: 861e938 d421682 Author: Steffen Neumann Date: Fri Feb 24 22:12:22 2017 +0100 Merge branch 'biocdevel' into devel commit 78a98b1e8c2612a847382ff741da49a90786c6c0 Author: jotsetung Date: Fri Feb 24 08:38:39 2017 +0100 Add columne "is_filled" to chromPeaks matrix commit 1743262d1d03865461bc489bf76fc0a566608f4e Author: jotsetung Date: Thu Feb 23 18:58:44 2017 +0100 Add findChromPeaks for XCMSnExp objects (issue #128) commit 8068dbeb2d955121179c6974b94c6aa7d7b0d610 Author: jotsetung Date: Thu Feb 23 13:26:21 2017 +0100 Rename parentMz in Chromatogram to precursorMz o Rename Chromatogram class slot parentMz into precursorMz to fit with the IUPAC definition. commit b358862912447e017ad9b9406cbe369abc357aae Author: jotsetung Date: Thu Feb 23 08:02:13 2017 +0100 spectra,XCMSnExp returning adjusted rtime (issue #129) o spectra,XCMSnExp returns adjusted rtime within the Spectrum objects, if such retention times are present in the XCMSnExp object. o Add related documentation and unit tests. commit 861e93805afcf2da1add7adfde71e403333c8fe0 Author: jotsetung Date: Wed Feb 22 11:06:19 2017 +0100 Fix issue #127: failing unit test on tokay2 build machine commit 2ae5eafdebe4c225d3a1de7b194a89093507d109 Author: jotsetung Date: Wed Feb 22 10:52:34 2017 +0100 Rename methods, functions and objects (issue #126) o Rename most of the methods from the new user interface to follow a common nomenclature. commit 009e57a15b6a2969d460144bec30b2b098485377 Author: jotsetung Date: Wed Feb 15 09:39:04 2017 +0000 Ensure memory cleanup in parallel findPeaks for xcmsSet commit 6da82fc146eb80e3058ce56cfe2bc536818fce82 Author: jotsetung Date: Wed Feb 8 12:15:02 2017 +0100 Minor changes to Chromatogram o Don't export Chromatogram. commit c4bca930c1f897e1fe3b3db6c01cfb6f7c456d27 Author: jotsetung Date: Mon Feb 6 08:27:36 2017 +0100 Add Chromatogram class o Add Chromatogram class (related to issue #120). o Add methods, unit tests and documentation. commit f6e169fbfbfe9ac9ee83d6677317def6b2714b8a Merge: b0deb92 84eee36 Author: Steffen Neumann Date: Fri Feb 3 09:59:01 2017 +0100 Merge branch 'biocdevel' into devel commit b0deb92a9b8df81fe7b2ea6e2129ae46bc282cfa Author: jotsetung Date: Fri Feb 3 09:20:54 2017 +0100 Bump version and update NEWS. commit 70040008b630ede4a8c5ff569fce27bf798a4616 Author: jotsetung Date: Fri Feb 3 08:40:41 2017 +0100 Fix issue #124 o Fix issue #124: filterRt,XCMSnExp returns empty object. o Extend unit tests for above fix. commit 2f1add71e4440547b006c5534ba10328f8f8feef Author: jotsetung Date: Thu Feb 2 18:48:02 2017 +0100 Bump version. commit 0c9b416ea9128ecbbce3ce567a71d7462b776cdb Author: jotsetung Date: Thu Feb 2 18:45:06 2017 +0100 Small internal changes. commit 09eb5e3f5e784157e8b50e159cef9c05cf725bc8 Author: jotsetung Date: Thu Feb 2 15:21:15 2017 +0100 Small code cleanup. commit 00fd415e0b14070b3bf9a417283b98a9a888c065 Author: jotsetung Date: Thu Feb 2 15:01:58 2017 +0100 Update NEWS. commit 806d79351a46d5369d2e056010ca33f6d7c5d5f4 Merge: 2d2ecf8 6e0381e Author: jotsetung Date: Thu Feb 2 14:48:35 2017 +0100 Merge branch 'devel' into xcms3 commit 2d2ecf85d66ce24309499c60834448694ac5eb60 Author: jotsetung Date: Thu Feb 2 14:18:48 2017 +0100 Fix unit test error on R-3.2.3 commit 7720ea5c0de35552ca8c25e782e1e9df7ab47023 Author: jotsetung Date: Thu Feb 2 12:20:49 2017 +0100 filterRt filtering by default on adjusted rt if available o Fix filterRt to filter on adjusted retention times if available. o Fix filterRt to filter features correctly for adjusted = FALSE. o Extend unit tests to ensure proper functionality. o Extend documentation. commit 7aeee29b3eaddceae9ba613083162b0a5066b6c7 Author: jotsetung Date: Thu Feb 2 07:28:23 2017 +0100 rtime,XCMSnExp reports by default adjusted rt o rtime,XCMSnExp method reports by default, if present, adjusted retention times (issue #123). o Add/fix related unit tests and adapt documentation. o Extend other documentations. commit 079836e67c1bb607759bd51e17edee66230cfb3a Author: jotsetung Date: Wed Feb 1 10:54:21 2017 +0100 Add groupval,XCMSnExp method (issue #114) o Add the groupval,XCMSnExp method. o Add documentation and unit tests. commit 359ad1c2492c0c3b334de29297465284b3eaa226 Author: jotsetung Date: Wed Feb 1 06:25:58 2017 +0100 Add adjustRtime,XCMSnExp,ObiwarpParam (issue #119) o Add adjustRtime obiwarp alignment for XCMSnExp and OnDiskMSnExp. o Add documentation and unit tests. commit d4ceb5f5fbae010575cf76f7ffffe130093639d3 Author: jotsetung Date: Mon Jan 30 09:10:53 2017 +0100 Tentative fix for issue #118 o Using checkEquals instead of checkIdentical on the failing unit test. commit d6df84b9c3ab052fc20d7591fb9d4a39de4db793 Author: jotsetung Date: Mon Jan 30 09:05:51 2017 +0100 Add ObiwarpParam class (issue #119) o Add the ObiwarpParam class. o Add related documentation and unit tests. commit 940fecdcc931cdc83b0011b6299b56affc3e5e98 Author: jotsetung Date: Fri Jan 27 06:56:51 2017 +0100 Implement profMat method for XCMSnExp and OnDiskMSnExp o Implement the profMat method for OnDiskMSnExp and XCMSnExp objects (issue #115). o Add related documentation and unit tests. commit 98b53f3ceff0b26c2ff9afc091cba73a8705442f Author: jotsetung Date: Wed Jan 25 14:59:47 2017 +0100 Use do_adjustRtime_featureGroups in retcor.peakgroups o Modify the retcor.peakgroups method to use the do_adjustRtime_featureGroups to perform the retention time correction (issue #111 and #112). o Add related unit test to compare to the original code. commit 4a2d9659ba665e0d3a5f032257666a703846db5f Author: jotsetung Date: Wed Jan 25 13:45:03 2017 +0100 Add adjustRtime,XCMSnExp,FeatureGroupsParam method o Add the retention time adjustment equivalent to retcor.peakgroups (issue #112). o Add related unit tests and documentation. o Enhance and fix the dropFeatures, dropFeatureGroups and dropAdjustedRtime methods and the features<-, featureGroups<- and adjustedRtime<- methods (see issue #113). o Add related documentation and unit tests. commit 569dff0f2a4148e04f0d2a83419d0b0f858ecbbe Author: jotsetung Date: Tue Jan 24 15:06:07 2017 +0100 Add FeatureGroupsParam object (issue #112) o Add FeatureGroupsParam object. o Add related unit tests and documentation. commit 1f866da1b7f80d91e35f16ca4b1ab055d3c2cc3e Author: jotsetung Date: Tue Jan 24 12:54:05 2017 +0100 Add documentation and unit test for do_adjustRtime_featureGroups o Add documentation and unit test for do_adjustRtime_featureGroups (issue #111). commit 27c382a2d9ed436a8071b38bebed7d24703568e7 Author: jotsetung Date: Tue Jan 24 12:18:08 2017 +0100 Amend ordering of peak goups in retcor.peakgroups (issue #110) commit 5d602d2185665c9feac159dacda58fdbaa36bfed Author: jotsetung Date: Tue Jan 24 09:18:34 2017 +0100 Add the do_adjustRtime_featureGroups function o The do_adjustRtime_featureGroups function performs retention time correction with the peakgroups method. Issue #111. commit 6c005cf0ea4346a124569a0e79015a6722136b8a Author: jotsetung Date: Fri Jan 20 16:26:56 2017 +0100 Remove commented code. commit 9b88134182343a19992fe99100d39c0c62b9242b Author: jotsetung Date: Fri Jan 20 16:13:21 2017 +0100 Add groupFeatures,XCMSnExp,NearestFeatures method (issue #108) o Add the groupFeatures,XCMSnExp,NearestFeatures method. o Add related unit tests and documentation. commit 73311ba4e6b4417f48d00a327168e2b5c47c3ca0 Author: jotsetung Date: Fri Jan 20 15:32:50 2017 +0100 Add NearestFeaturesParam class (issue #108) o Add the NearestFeaturesParam class with all methods and functions. o Add related documentation and unit tests. commit dde4b3a9d585c33bc91c2705b696e53a2a73d21d Author: jotsetung Date: Fri Jan 20 13:15:36 2017 +0100 Fix warnings in group.nearest (issue #109) commit ec0daf60ed1c6d01e696dc7e927c25d10b651912 Merge: 8fd3010 8312b64 Author: jotsetung Date: Fri Jan 20 11:10:29 2017 +0100 Merge branch 'xcms3' of https://github.com/sneumann/xcms into xcms3 commit 8fd301034eefa35e87dbbccb47aec86643e79297 Author: jotsetung Date: Fri Jan 20 10:38:28 2017 +0100 Add do_groupFeatures_nearest function (issue #103) o Add the do_groupFeatures_nearest function. o Add unit tests and documentation. commit 8312b6469d37fc923c0cd6ac6bc1a17bcd4eec59 Author: jotsetung Date: Fri Jan 20 10:38:28 2017 +0100 Add do_groupFeatures_nearest function (issue #103) o Add the do_groupFeatures_nearest function. o Add unit tests and documentation. commit 848b6c21d1fcd6bab86a669c78de1a3a3594d445 Author: jotsetung Date: Thu Jan 19 16:02:03 2017 +0100 Add groupFeatures,XCMSnExp,MzClustParam (issue #107) o Add groupFeatures,XCMSnExp,MzClustParam method. o Add documentation and unit tests. commit 8f4230089e538631d87bc30b45c0b1c5a640e474 Author: jotsetung Date: Thu Jan 19 14:43:22 2017 +0100 Add MzClustParam class and smaller bug fixes o Add the MzClustParam class along with all required methods (issue #107). o Add unit tests and documentation. o Add support for R-3.2.3: fix problems with S4Vectors and sort method. commit a98f9fb67ec76eb9cc6905533f50b9e60f9a65c4 Author: jotsetung Date: Wed Jan 18 16:13:45 2017 +0100 Fix order issue (issue #180 in MSnbase) o Remove argument 'method' from any calls to order to ensure backward compatibility. commit 5c11a30aeef599220a8a87188fb8e50552beb19f Author: jotsetung Date: Wed Jan 18 06:55:23 2017 +0100 Add do_groupFeatures_mzClust function (issue #103) o Add the do_groupFeatures_mzClust function. o Add unit tests and documentation. commit 797ec556f78cb3e241a8bccd90f06c615126170d Author: jotsetung Date: Tue Jan 17 15:53:54 2017 +0100 Add groupFeatures,XCMSnExp,FeatureDensityParam method o Add the groupFeatures,XCMSnExp,FeatureDensityParam method to perform the feature alignment using the density method (issue #105). o Add unit test and documentation. commit 900c1d14f6343c2da8f3cf7515e8c77d9ac0bf0c Author: jotsetung Date: Tue Jan 17 14:06:35 2017 +0100 Add FeatureDensityParam class (issue #105) o Add the FeatureDensityParam class, all related methods and functions. o Unit tests and documentations for FeatureDensityParam. commit bb2f22a0f092d99527dde11c7c8fc99145979d6b Author: jotsetung Date: Tue Jan 17 11:01:24 2017 +0100 Parallel version of the do_groupFeatures_density implemented o Function implemented but not exported - no performance increase with the parallel version. commit 458b9e353ea184d861d21e27ce08fcefe300cce9 Author: jotsetung Date: Tue Jan 17 10:19:10 2017 +0100 Replace code in group.density with do_groupFeatures_density (#103) commit 9edb01c2d9986d15d48d65ce95ed00edc86901bc Author: jotsetung Date: Tue Jan 17 09:22:08 2017 +0100 Add do_groupFeatures_density function o Add the first feature alignment core API function: do_groupFeatures_density: issue #103. o Add unit tests and documentation. commit 6e0381eef656d2f32fa8d3affabd2a9f995bfc38 Merge: 87a57f1 283023b Author: Steffen Neumann Date: Tue Jan 17 08:28:38 2017 +0100 Bump version and adapt NEWS commit 87a57f1c4d1ab4da77093dc529ed4def9b1bc0e2 Merge: 5e288f4 62452c2 Author: Steffen Neumann Date: Mon Jan 16 22:57:21 2017 +0100 Merge remote-tracking branch 'origin/xcms3' into devel commit 5e288f41000a7aab07e2b0e4cc61232fb7baa1f3 Merge: a4421c3 4c6815a Author: Steffen Neumann Date: Mon Jan 16 22:57:07 2017 +0100 Merge branch 'biocdevel' into devel commit 62452c2b5204f515e57579aaa8c614173c44750b Author: jotsetung Date: Mon Jan 16 12:57:22 2017 +0100 Removed , in DESCRIPTION commit bdc3d65b646447f4b7fef7ba650623d2bcacb87f Author: jotsetung Date: Fri Jan 13 21:28:54 2017 +0100 Add spectrum,XCMSnExp method and increase method robustness o Add spectrum,XCMSnExp method to extract spectra grouped by samples (bySample parameter). Issue #96. o Ensure robustness of methods with a bySample parameter: the returned list has always the same length as there are files, with elements being empty if no e.g. mz values are present for a specific file (because it got e.g. filtered). commit d8e9a21f1ed58e0167e68164c2b98f48e0f826fb Author: jotsetung Date: Fri Jan 13 13:33:54 2017 +0100 Fix issue #102 commit 95f5c30fdd727e0419de928553121d204e032ae4 Author: jotsetung Date: Fri Jan 13 13:29:26 2017 +0100 Fix issue #91. o Replay the changes made by Jan Stanstrup. commit 839fdb369875f895c06d627dedbe5161e3600f2c Author: jotsetung Date: Fri Jan 13 13:17:31 2017 +0100 Fix issue #98 o Fix error in flagme vignette. Ensure that number of rows of the profile matrix is equivalent to what produced in the old code. Problem was that previously the mzrange of the xcmsRaw object was altered, i.e. represented rounded *real* mz range. The number of rows in the profile matrix were then equal to the length of the sequence seq(mzrange[1], mzrange[2], by = step). The new code however always ensures that the real max mz value is included, i.e. it produces one more bin in cases were in the old approach the max mz would have been floored (new code: always do ceiling). commit c602fef616c8060b196c00f933fe22c6ee289394 Author: jotsetung Date: Fri Jan 13 08:01:13 2017 +0100 Add bySample parameter to features,XCMSnExp o Add the bySample parameter to the features,XCMSnExp method allowing to extract the feature matrices grouped by sample. commit f7053990d515702911850aa400908f4e5d7c5b14 Author: jotsetung Date: Thu Jan 12 16:21:50 2017 +0100 Fix for the last improvement of the issue #99 fix. commit 223798c30f8852d3c4696f4284facbe4152a08c8 Author: jotsetung Date: Thu Jan 12 07:58:19 2017 +0100 Update NEWS. commit 277324fec07683db2b08e09c0077ce243f9d327f Author: jotsetung Date: Thu Jan 12 07:53:47 2017 +0100 Improve fix for issue #99 o Only throw an error if the rtrange is completely outside the available rt. commit 707990ee9ae0f27e8d7e7fd3b5c8e6ef6048db90 Author: jotsetung Date: Wed Jan 11 08:28:01 2017 +0100 Method to coerce XCMSnExp to xcmsSet o Add setAs method to coerce XCMSnExp to xcmsSet (issue #100). o Add related unit tests and documentation. o Add examples for XCMSnExp usage. commit 9419493c8dda575dd6e74417e62d2c3a62989394 Author: jotsetung Date: Tue Jan 10 16:10:47 2017 +0100 Fix issue #101 o Fix the xcmsRaw function to not copy over MSn data if msleve = 1 is provided. commit 804e8bca6f6322b42ffa88467b1ff2e45038a819 Author: jotsetung Date: Tue Jan 10 09:15:50 2017 +0100 Add filterRt method for XCMSnExp o Implement the filterRt method for XCMSnExp objects that allows to filter the object by retention time. Subsets also features, featureGroups and adjusted retention time. Issue #96. commit 0bcb852e280294f0d58e016d69f1ad02c6368bbd Merge: 48055c0 7962641 Author: jotsetung Date: Mon Jan 9 16:01:17 2017 +0100 Merge remote-tracking branch 'refs/remotes/origin/xcms3' into xcms3 commit 48055c072e5589fa2fd3351b5a14de0b5bbc3a9b Author: jotsetung Date: Mon Jan 9 08:16:42 2017 +0100 Add bySample argument to adjustedRtime,XCMSnExp method o Add the bySample argument to the adjustedRtime,XCMSnExp method. commit 79626414dd15957ebec9d47c1dc18ccba9b85dab Author: jotsetung Date: Mon Jan 9 08:16:42 2017 +0100 Add bySample argument to adjustedRtime,XCMSnExp method o Add the bySample argument to the adjustedRtime,XCMSnExp method. commit 2e30a970c7e091bfdd575397985cfe1d985d0cca Author: jotsetung Date: Mon Jan 9 06:52:03 2017 +0100 Add mz, intensity and rtime methods for XCMSnExp o Add mz, intensity and rtime methods for XCMSnExp objects extending the corresponding methods for OnDiskMSnExp by adding the bySample parameter. commit 4aa10f595f103f2f8a7ef9b080a4407b3a41dd3a Author: jotsetung Date: Fri Jan 6 22:24:13 2017 +0100 Use drop* methods to remove preprocessing results o Use the drop* methods to remove preprocessing results from XCMSnExp objects. commit 8f1fc5cba7ea93c47ff60bdc76a5799693d09249 Author: jotsetung Date: Tue Jan 3 18:29:41 2017 +0100 Add sort method option o Add sort method option that defaults to "auto" on R versions < 3.3. See https://github.com/lgatto/MSnbase/issues/180 for more info. commit 6ae59333718b341ce3b40ec74b4e83007e975ed4 Author: jotsetung Date: Mon Jan 2 21:22:48 2017 +0100 Fix failed execution of unit tests commit a1122065a96cf6e69088417d82fe987cda188cd5 Author: jotsetung Date: Fri Dec 30 21:57:02 2016 +0100 Add drop methods o Add dropFeatures, dropFeatureGroups and dropAdjustedRtime for XCMSnExp and MsFeatureData objects to remove the corresponding results. o Remove obsolete Rd files. commit 477f0db3fd58f0aedef21e06d062b2f19e86f5c2 Merge: e92a02d a4421c3 Author: jotsetung Date: Sun Dec 25 18:49:49 2016 +0100 Merge branch 'devel' into xcms3 commit e92a02d2b0bb24bb9c58b615879f430fa35a9b61 Author: jotsetung Date: Fri Dec 23 15:27:37 2016 +0100 Implement filterMz method for XCMSnExp o Add the filterMz method for XCMSnExp that allows filtering on an mz value range. features and featureGroups are retained if they are completely within the mz range. Adjusted retention time is not altered. o Add unit tests and documnentation. commit 6dec3689c906b8557ebfe3bee91c1592e22852a2 Author: jotsetung Date: Fri Dec 23 14:04:37 2016 +0100 Fix problem reading MS2-only files. o Fix issue https://github.com/MassBank/RMassBank/issues/174 commit 9c9319da5bd9be139648680805fb59d175a4abea Author: jotsetung Date: Fri Dec 23 12:29:03 2016 +0100 Implement some of the methods inherited from OnDiskMSnExp o Implement all data manipulation methods from OnDiskMSnExp for XCMSnExp class (issue #96). All drop xcms pre-processing results. o Implement filterFile for XCMSnExp, does subset identified features. o Add documentation and unit tests. commit a4421c35caef0aaee129a222c128c99c25b218a5 Merge: 62932b7 1ddbb89 Author: Steffen Neumann Date: Fri Dec 23 12:01:16 2016 +0100 Merge branch 'devel' of github.com:sneumann/xcms into devel commit 62932b77c7407c04ed0d49bbe7d7ad2cf82371f0 Author: s.neumann Date: Fri Dec 23 11:00:28 2016 +0000 added deepCopy to avoid corrupting the original object, thanks to J. Stanstrup, closes #93 git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@125419 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 2ab8350f93056ba300eee06b7ef14212bd65ceaf Author: s.neumann Date: Fri Dec 23 11:00:19 2016 +0000 added deepCopy to avoid corrupting the original object #76 git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@125418 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 832f67adc75df88264aa017361788f2b2632da91 Author: jotsetung Date: Fri Dec 23 06:37:34 2016 +0100 Code cleanup o Comment unneeded (mostly testing purpose only) functions. o Remove previously commented out functions and code. o Add xcms startup message. commit c0ac4b7c622ccb211fcbb526a649e05ec514536f Author: jotsetung Date: Thu Dec 22 16:22:15 2016 +0100 Extend show method for XCMSnExp objects. commit a58cf39f9ebde3e6dc3ee94795fd3cb9addb18e5 Author: jotsetung Date: Thu Dec 22 15:23:36 2016 +0100 Enable XCMSnExp as return object in detectFeatures o Return the XCMSnExp object as a result object from the detectFeatures method. o Add related unit tests and update documentation. o XCMSnExp is ready to run (issue #85). commit 46c27495d87083dd41890e9ec2663f3ae669ef3d Author: jotsetung Date: Thu Dec 22 13:38:19 2016 +0100 Export the ProcessHistory and XProcessHistory classes o Export the ProcessHistory and XProcessHistory classes allowing to keep track of performed data analysis steps. o Add the processHistory method for XCMSnExp objects. o Add unit tests and documentations. commit 1fbf8b525a7557239c24296c62b4d98b9860e226 Author: jotsetung Date: Wed Dec 21 21:45:45 2016 +0100 Implement the detectFeatures method for CentWavePredIsoParam o Implement the detectFeatures method for CentWavePredIsoParam class. o Add documentation and unit tests. commit a3324552b94599b38995f117e9f3ce860465d83a Author: jotsetung Date: Wed Dec 21 16:34:47 2016 +0100 Add rtime,XCMSnExp method o Add rtime,XCMSnExp method that returns the retention time grouped per sample. commit f5f7d04610e4d1aeb2cbbd4b4315f89568317b66 Author: jotsetung Date: Wed Dec 21 15:48:09 2016 +0100 Add XCMSnExp class o Add the XCMSnExp class and export the MsFeatureData class (issue #85). o Add methods hasAdjustedRtime, hasAlignedFeatures, hasDetectedFeatures, features, features<-, featureGroups, featureGroups<-, adjustedRtime, adjustedRtime<-. o Add unit tests and documentation. commit cb148d5da0527462b548f0da04274ed8b505764c Author: jotsetung Date: Wed Dec 21 12:20:15 2016 +0100 Add MsFeatureData class o Add the MsFeatureData class for storing xcms preprocessing results (see issue #85 and https://github.com/lgatto/MSnbase/issues/177). o Add unit tests and validity function for the new object. commit 1ddbb890ddb2e5d741571c79647821c6d96c14a6 Author: Steffen Neumann Date: Tue Dec 20 22:14:46 2016 +0100 added deepCopy to avoid corrupting the original object, thanks to J. Stanstrup, closes #93 commit 37280ef115738daccd392c10f9e4b4fe5f6543a6 Merge: 5160700 fef11aa Author: Steffen Neumann Date: Tue Dec 20 21:43:15 2016 +0100 Merge branch 'stanstrup-patch-3' into devel commit fef11aac12ca51f227ac9302fe960997563e11a3 Merge: 5160700 ba80552 Author: Steffen Neumann Date: Tue Dec 20 21:43:02 2016 +0100 Merge branch 'patch-3' of git://github.com/stanstrup/xcms into stanstrup-patch-3 commit 5160700df8728f54c4460a0054ba975b05662f05 Merge: 8b595bf 647e2f9 Author: Steffen Neumann Date: Tue Dec 20 21:41:28 2016 +0100 Merge branch 'devel' of github.com:sneumann/xcms into devel commit 8b595bf187e6f97de4d19508c7faab73062ad593 Author: s.neumann Date: Tue Dec 20 20:39:30 2016 +0000 adapted manpage for plotQC From: Steffen Neumann git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@125356 bc3139a8-67e5-0310-9ffc-ced21a209358 commit b95b7689e622b50e55f76c2caaf19c25e6071c32 Author: s.neumann Date: Tue Dec 20 20:39:20 2016 +0000 merged xcms3 branch, added return value to plotQC() From: Steffen Neumann git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@125355 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 647e2f9c5fc7e6ea40d839c9846b07d668a95f0d Author: Steffen Neumann Date: Tue Dec 20 21:34:30 2016 +0100 adapted manpage for plotQC commit cf29b17d73c32bb0b89f7b7166fcb9cf9decec1e Author: Steffen Neumann Date: Tue Dec 20 21:32:50 2016 +0100 merged xcms3 branch, added return value to plotQC() commit ba805525dda98a90d9dd4682fbbdd0318bbab01d Author: Jan Stanstrup Date: Tue Dec 13 11:34:53 2016 +0100 added deepCopy to avoid corrupting the original object #76 commit dde6cba65156aedd28c36be89e64944d4e4e3389 Merge: d771f06 3385098 Author: jotsetung Date: Tue Dec 13 11:26:02 2016 +0100 Merge branch 'devel' into xcms3 commit 33850986e49365cbbdab5a0cffce65378db8ed35 Author: s.neumann Date: Tue Dec 13 10:14:49 2016 +0000 do not error if a centWave ROI contains no data, closes #90 git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@125062 bc3139a8-67e5-0310-9ffc-ced21a209358 commit bc99d3d47fb913a9ae13525b88186f1209fc08ae Merge: 58c2ad2 ba781a1 Author: s.neumann Date: Tue Dec 13 10:14:41 2016 +0000 Merge branch 'stanstrup-patch-2' git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@125061 bc3139a8-67e5-0310-9ffc-ced21a209358 commit ba781a1ba412e303fbd36673baf1e078495e0362 Merge: 58c2ad2 cba193b Author: Steffen Neumann Date: Tue Dec 13 11:11:47 2016 +0100 Merge branch 'patch-2' of git://github.com/stanstrup/xcms into stanstrup-patch-2 commit 58c2ad22057adfe1d4c7da5d06ffa75e1309a70e Author: s.neumann Date: Tue Dec 13 09:52:50 2016 +0000 Merge fix and bump version git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@125060 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 99b0eee8ca8ac60542c28065e3125cce20e09458 Merge: 2bf72a8 02444fd Author: s.neumann Date: Tue Dec 13 09:52:13 2016 +0000 Merge remote-tracking branch 'sneumann/devel' git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@125059 bc3139a8-67e5-0310-9ffc-ced21a209358 commit d771f06e483f8d579ba918e4b5fa56834f53d02f Author: jotsetung Date: Tue Dec 13 08:16:05 2016 +0100 Add CentWavePredIsoParam class o Add CentWavePredIsoParam class, documentation and unit tests. commit 515b8141ab02e3726cdc52cdb69f130a5ef9f689 Author: jotsetung Date: Mon Dec 12 15:24:55 2016 +0100 Add centWaveWithPresIsoROIs core API function o Add do_detectFeatures_centWaveWithPredIsoROIs function (issue #82, #35). o Change the findPeaks.addPredictedIsotopeFeatures and findPeals.centWaveWith... to use the new do_ function. o Unit test to compare original implementation with the new one. commit 3232b82c34254459f2d71d0a4c7a0b8e970ad641 Merge: 0d9d13e 02444fd Author: jotsetung Date: Sun Dec 11 19:21:14 2016 +0100 Merge branch 'devel' into xcms3 commit 02444fdc4f3e2264d7ff85e7320e9df955969379 Author: jotsetung Date: Sun Dec 11 19:04:11 2016 +0100 Fix wrong sample indexing in getEIC,xcmsSet o Fix the wrong sample indexing in getEIC,xcmsSet: issue #92. commit 0d9d13ec4fe9e9d0b24a4530297d436fe61b56a6 Author: jotsetung Date: Sat Dec 10 22:19:13 2016 +0100 Start implementing the do function for withAddIsotopes commit cba193bdeac458b978628c66d02a9dfdef69e1c6 Author: Jan Stanstrup Date: Fri Dec 9 11:05:45 2016 +0100 More informative warning. commit 9dc277bfeebd257b967645e61fb817c732ce16a3 Author: jotsetung Date: Thu Dec 8 12:24:43 2016 +0100 change profStepPad to use new binning functions o change profStepPad, used in retcor.obiwarp, to use new binning functions. o Ensure consistent naming of data types for parameters in roxygen documentation. commit 94b2b7f3048cd5e944b62631ea99ee772df78e00 Author: jotsetung Date: Thu Dec 8 09:51:28 2016 +0100 Update new_functionality vignette to new BiocStyle o Update the new_functionality vignette to correctly use the BiocStyle package. o Add the xcms.org org-file representing the future vignette describing xcms3 in detail. commit fd47069e84bc2b4f519b27db9d566f42cbdb9952 Author: jotsetung Date: Mon Dec 5 15:58:54 2016 +0100 Finish unit test tuning o Reduce processing time in the remaining unit tests. commit cb382f6bf4c20a568903ad549e3d9e72146d6ea7 Author: jotsetung Date: Fri Dec 2 12:57:45 2016 +0100 Unit test tuning o Tuning some more unit tests. o Disable the benchmarking vignette. commit 9fdf8a952bccabe19153d98b5371f5eabd8608a2 Author: jotsetung Date: Thu Dec 1 16:23:08 2016 +0100 Fix vignettes and tune unit tests o Disable parallel processing for R CMD check. o Fix BiocStyle templates in the new vignettes. o Tune unit tests and examples. commit 88322830e22aa9ce19749fbd1b7f40703fe22743 Merge: cd9165b bf142bc Author: Johannes Rainer Date: Thu Dec 1 14:43:15 2016 +0100 Merge pull request #88 from Treutler/xcms3 implemented function "do_predictIsotopeROIs" (issue #82) commit bf142bc4db56af7d66a06e2caee165147ae6ed9c Author: Treutler Date: Thu Dec 1 14:03:40 2016 +0100 split the functionality of "findPeaks.addPredictedIsotopeFeatures" / "findPeaks.centWaveWithPredictedIsotopeROIs" and implemented function "do_predictIsotopeROIs" commit cd9165bac43e205ffd3391ffa64aac7f42c5dac1 Author: jotsetung Date: Thu Dec 1 11:21:49 2016 +0100 Add MSW detectFeatures method o Add the detectFeatures,xxMSnExp,MSWParam method (issue #87). o Add documentation for massifquant detectFeatures method (issue #84). o Update NEWS. commit 8ace0ea8ddeefe383017920cac2a7316108473a5 Author: jotsetung Date: Wed Nov 30 14:53:49 2016 +0100 Add massifquant detectFeatures method o Implement the MassifquantParam class and the detectFeatures method (issue #84). o Implement the MSWParam class (issue #87). commit 35b3b7e476d918d7836ac6317bedb5c4ec92f60f Author: jotsetung Date: Mon Nov 28 14:59:09 2016 +0100 Add XProcessHistory class o The XProcessHistory class extends the ProcessHistory class and allows to add a Param class to the @param slot with the settings of the processing step. o Notes and ideas of the new XCMSnSet object. commit ccecc8f3bc62ffd0245f3a23b2f3a6e85c833b9d Author: jotsetung Date: Sun Nov 27 18:44:50 2016 +0100 Just some comments commit dd8cbd3c8f5aaa6e8633f7aee5185f4df009d9d4 Author: jotsetung Date: Sun Nov 27 08:34:34 2016 +0100 Add MassifquantParam class o Add a MassifquantParam class (issue #84). commit a6bfa83e3d5cce6dbfc4ce9416aaff873275d4ca Author: jotsetung Date: Fri Nov 25 11:52:56 2016 +0100 Add warning if data is not in centroid mode for centWave commit 284408213e7c410e2a09e68697c737524851ed03 Author: jotsetung Date: Fri Nov 25 11:32:37 2016 +0100 Add documentation for detectFeatures centWave and matchedFilter o Complete the missing documentation for the parameter classes and methods and the detectFeature methods (issue #83). commit 5b1e7a261f9b69dcb79792fdb83ee02807b73589 Author: jotsetung Date: Fri Nov 25 10:06:47 2016 +0100 Implement MatchedFilterParam and detectFeatures method o Add the MatchedFilterParam class and related methods. o Implement the detectFeatures,MSnExp,MatchedFilterParam and detectFeatures,OnDiskMSnExp,MatchedFilterParam methods (issue #83) o Add related unit tests. commit c4990197c14f30f40278e8c29f3e443574800ee7 Author: jotsetung Date: Thu Nov 24 10:38:38 2016 +0100 Add detectFeatures method for MSnExp and OnDiskMSnExp objects o Implement detectFeatures,MSnExp,CentWaveParam and detectFeatures,OnDiskMSnExp,CentWaveParam methods to perform feature detection using centWave on MSnExp and OnDiskMSnExp objects from the MSnbase package (issue #79). o Add unit tests evaluating correct processing. o Add roiList parameter validation to CentWaveParam class. commit e464617e26015c18f53303226e678adb9e70299b Author: jotsetung Date: Thu Nov 17 12:33:46 2016 +0100 Add CentWaveParam class (issue #78) o Add a Param and CentWaveParam class to pave the road for the feature detection framework. commit 27cf041f62238cf4e81a193e2b5f622724557c3a Author: jotsetung Date: Mon Nov 7 11:02:49 2016 +0100 Fix remaining unit test errors o Fix all unit test errors due to profBin function deprecation and new getEIC method (issue #68). o Add additional unit tests to ensure getXcmsRaw and [ subsetting works also along with specifying scanrange. commit ddc4e6f571bb9ed06d3bc54c93fc102ccf67c90f Author: jotsetung Date: Fri Oct 28 19:34:26 2016 +0200 Update getEIC method o getEIC method uses now the new binning and linear interpolation functions (issue #74). commit 348a598f05dd99d5fa4452a93aec4a9620453133 Author: jotsetung Date: Thu Oct 27 10:47:16 2016 +0200 Fix warnings in specDist o Fix warnings in specDist method (issue #73). commit b7cd5c9f919779100f2a6fa044835ee82e28d012 Author: jotsetung Date: Thu Oct 27 08:56:50 2016 +0200 Fix subsetting and profile matrix generation issues o Fix scanrange subsetting in xcmsRaw function (issue #69). o Avoid duplicated profile matrix generation in xcmsRaw function issue #72. o Add profMat method (issue #71). o Fix profStep<- and profMethod<- to avoid profile matrix generation when not needed. commit a98067ade4b5e03997f8c04d2897fe99391bd73f Author: jotsetung Date: Mon Oct 24 16:13:57 2016 +0200 Deprecate old binning functions. o Deprecate the profBin, profBinM, profBinLin, profBinLinM, profBinLinBase and profBinLinBaseM functions. commit 0ba4586a16b142fa10992b9c929051c5f1f21b93 Author: jotsetung Date: Mon Oct 24 08:03:08 2016 +0200 Change data import to newer mzR methods + Use `header` and `peaks` methods from mzR for data import instead of un-exported private methods. + Fix issue #67: add argument dropEmptyScans in readRawData to emulate the _old_ behaviour to discard empty scans. + Update new_functionality.Rmd. commit 93c216f8269868d13ddf824d55b4eef1c4f6a1e0 Author: jotsetung Date: Fri Oct 21 09:26:36 2016 +0200 Update the new_functionality.Rmd vignette. commit 31139f05c72360f84ed7aec20b7a19efadf81928 Merge: fa2fb9b fa4a97f Author: jotsetung Date: Fri Oct 21 09:20:17 2016 +0200 Merge branch 'devel' into xcms3 commit fa2fb9b054e06bfa4fb25ca8ac1eeb1286b77137 Author: jotsetung Date: Fri Oct 21 09:04:26 2016 +0200 Use official mzR methods for data import o Remove use of private ::: methods from mzR for data import and use the official 'header' and 'peaks' methods (issue #65). o Fix issue #66. commit b800586682acc62b63edb8954ad885f06fe434a4 Author: jotsetung Date: Thu Oct 20 11:19:39 2016 +0200 Change matchedFilter to use new binning code o Change findPeaks.matchedFilter and do_detectFeatures_matchedFilter to use the new binning code that performs the binning on the full matrix. This relates and fixes issues #47 and #52. o Change default in useOriginalCode to FALSE. commit 0036470d847cda9d1370194835a3748d5f2acab3 Author: jotsetung Date: Thu Oct 20 06:59:38 2016 +0200 Update findPeaks.centWave to use the do_ function o Update findPeaks.centWave to use the do_detectFeatures_centWave function. o Fix subsetting by scanrange in centWave (issue #64). commit 9611dae1e9689d67cbbfba2ceb1b5d215b921adc Author: jotsetung Date: Wed Oct 19 15:13:12 2016 +0200 Fix scanrange parameter in findPeaks methods o Fix problems with the scanrange parameter in findPeaks methods: - findPeaks.massifquant: parameter was ignored (issue #61). - findPeaks.matchedFilter: parameter was partially ignored (issue #63). - findPeaks.centWave: spectra were sub-setted, but @scantime not (issue #64). commit fa4a97f903ad8dba16cad0b3247f25d85dc27d93 Author: hpages@fhcrc.org Date: Mon Oct 17 19:10:43 2016 +0000 bump x.y.z versions to odd 'y' after creation of 3_4 branch git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@122712 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 1f816d946ed079f95dc4efa4e0aaa7cca360ef64 Author: hpages@fhcrc.org Date: Mon Oct 17 18:45:06 2016 +0000 bump x.y.z versions to even 'y' prior to creation of 3_4 branch git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@122710 bc3139a8-67e5-0310-9ffc-ced21a209358 commit baf28d1d1b3d9a32f20a485e5867b40369c73723 Author: jotsetung Date: Wed Sep 28 09:41:16 2016 +0200 Update the do_detectFeatures_centWave function o Update the do_detectFeatures_centWave function to the latest code. o Fix a bug in the [ method for xcmsRaw. commit 8a65c66a1d535603cf1b6f584099c7a0d06eda1b Author: jotsetung Date: Tue Sep 27 08:21:56 2016 +0200 Fix issue #60 o Fix issue #60. o Add documentation for do_detectFeatures_massifquant. commit 50848696d4fdfdd5f6c81f2c12f3e8d8e7f4bfb0 Merge: f82432a 4b2458e Author: jotsetung Date: Tue Sep 27 06:36:00 2016 +0200 Merge branch 'devel' into xcms3 o Fix conflicts in methods-xcmsRaw.R and NEWS. commit 4b2458e54e11a874fd5a0ce42cfb4d4e475a2865 Author: s.neumann Date: Mon Sep 26 14:28:09 2016 +0000 Bump version and add NEWS on documentation fixes git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@121387 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 87c0eb5ffac14b74133d4a3a84e18e78ee9a4bf3 Merge: 0574910 39e1823 Author: s.neumann Date: Mon Sep 26 14:28:01 2016 +0000 Merge branch 'Treutler-devel' into devel git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@121386 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 05749105ac97b83938dc11705a57a8c1165522c6 Author: s.neumann Date: Mon Sep 26 14:26:19 2016 +0000 updated NEWS and bumped version git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@121385 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 39e1823fb1ed38a76c77b8e061af0024a7d09c7f Author: Hendrik Treutler Date: Mon Sep 26 15:22:00 2016 +0200 fixed WARNINGS commit f82432a125e222d9a9ab475cdd47d36c2da1b458 Author: jotsetung Date: Mon Sep 26 08:19:46 2016 +0200 Add [ method for xcmsRaw objects o Implement a [ method for xcmsRaw objects allowing to sub-set the object to specified scans/spectra. o Implement the do_detectFeatures_massifquant function. o Unit tests for the above method/function. commit 9f35b91e6c6381ce6892d15b95b5ab9b70c02c3f Author: jotsetung Date: Fri Sep 23 13:48:10 2016 +0200 Fix NEWS and remove unused variables from C code o Remove unused variables from C/C++ code. commit 536aa23e1c07bedae1083ff7bee400efdc8dcc79 Author: jotsetung Date: Fri Sep 23 13:16:24 2016 +0200 Fix issue #59 o Fix passing arguments in the wrong order in do_detectFeatures_MSW. o Fix a small bug in diffreport (wrong variable name for a directory). commit 873b11d4f8d15c09e294ef3983ad62f8ac43a5ee Author: jotsetung Date: Fri Sep 23 12:35:38 2016 +0200 Fix issue #58 and prepare massifquant do function o Fix the bug in rawMat,xcmsRaw method (issue #58). o Prepare the "do" function for massifquant. commit 5a505865868ae409ea01a1be81741ee1a0c8b009 Author: jotsetung Date: Tue Sep 20 14:09:17 2016 +0200 Add .processHistory slot to xcmsSet o Add .processHistory slot, ProcessHistory class and functionality to track processing steps. o Add unit tests for subsetting, splitting and concatenating of xcmsSet objects checking that .processHistory slot is processed correctly. o Add showError method for xcmsSet objects that lists eventual errors during the feature detection step. o This addresses discussions in issue #55. commit 5313459da83183f6f24576f03fe3ebd62b024a43 Author: jotsetung Date: Mon Sep 19 13:16:02 2016 +0200 Add argument stopOnError to xcmsSet function o Add argument stopOnError to xcmsSet to enable feature detection in all provided files without stopping on errors. This relates to issue #55. o Add related documentation. commit fb93c843fc40ee7a41ede3f1a3746d7c7e13cd46 Author: Hendrik Treutler Date: Wed Sep 14 10:54:18 2016 +0200 corrected documentation commit b228271555c2144e8d557d5b940e4a43f2753542 Merge: d9ba200 5b73c67 Author: Hendrik Treutler Date: Mon Sep 12 11:28:40 2016 +0200 bug fix Merge branch 'devel' of https://github.com/sneumann/xcms into devel Conflicts: NAMESPACE R/AllGenerics.R R/methods-xcmsRaw.R inst/unitTests/runit.findPeaksCentWaveWithIsotopeROIs.R commit ea0e449bbd7a040b4fd6d63cad3d8cb35b6df594 Author: jotsetung Date: Mon Sep 12 08:37:36 2016 +0200 Documentation fixes and code tidying commit 330ae95620bd2ad2f15aa74066b04d5b52cd0e2c Author: jotsetung Date: Fri Sep 9 20:34:37 2016 +0200 Add do_detectFeatures_MSW function. commit f3fc2b4000217f728a9b7acbabcd6ffa6c280a73 Author: jotsetung Date: Wed Sep 7 16:29:38 2016 +0200 Re-organize IO functions o Put new IO functions into functions-IO.R commit c812cda0cea2a06b78571b54ab5c707489eafa22 Author: jotsetung Date: Wed Sep 7 14:15:02 2016 +0200 New data import function o Add new readRawData function that could replace the loadRaw and related S4 objects; this aims to fix issue #55. o Start implementing do_detectFeatures_MSW. commit 9bce991e2ed0b66289f88030e57e5db121ed8368 Author: jotsetung Date: Tue Sep 6 11:34:52 2016 +0200 Update NEWS commit 16ac3ddeb24f8bcecc7290d00c93a28daeb0ad27 Merge: 4f46f61 5b73c67 Author: jotsetung Date: Tue Sep 6 11:23:04 2016 +0200 Merge branch 'devel' into xcms3 commit 4f46f61127bb7b4fee037b10b57e67a2d070cd1b Author: jotsetung Date: Tue Sep 6 11:04:52 2016 +0200 Add .Rbuildignore and update .gitignore commit d9ba200c61b7d6886f527b3d17ce6361edc89b2a Author: Hendrik Treutler Date: Tue Sep 6 08:51:13 2016 +0200 splitted method 'findPeaks.centWaveWithPredictedIsotopeROIs' into two more modular methods; removed parameter list and added individual parameters instead; added documentation for new methods commit 1bea5114fcce0796bb8f98a9e624317130934d80 Author: jotsetung Date: Mon Sep 5 13:53:27 2016 +0200 Add matchedFilter benchmarking commit 5b73c67688add8718c998763a9d9053ea2885511 Merge: 897da00 71d4d46 Author: Steffen Neumann Date: Mon Sep 5 13:28:58 2016 +0200 Merge branch 'devel' of github.com:sneumann/xcms into devel commit 897da00d22770f3ae8d494133d3fec85ed31aaaa Author: s.neumann Date: Mon Sep 5 11:13:31 2016 +0000 Bump version, add NEWS git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@120725 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 915d8bc1c2d3c7f4ad65ac2c5474f2c055c6e2ae Author: s.neumann Date: Mon Sep 5 11:13:24 2016 +0000 minor bug fix in unit test git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@120724 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 550d3e2dfdb1fdf4dd3ca41f4eaa313a481347c6 Author: s.neumann Date: Mon Sep 5 11:13:16 2016 +0000 Bug fix in case of small m/z ranges from peak picking using centWave and bug fix regarding scantime ranges git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@120723 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 73ac8a908dc445e745f0a3e3c42108621ec27750 Author: s.neumann Date: Mon Sep 5 11:13:08 2016 +0000 Added standard generic git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@120722 bc3139a8-67e5-0310-9ffc-ced21a209358 commit a989bbdc350bd34b3a2606e8b982ce0bf99d2b16 Author: s.neumann Date: Mon Sep 5 11:13:01 2016 +0000 Added function findPeaks.centWaveWithPredictedIsotopeROIs for the sensitive detection of isotope peaks based on predicted isotope ROIs git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@120721 bc3139a8-67e5-0310-9ffc-ced21a209358 commit b688d92f0ac223e6bc19db0140957a9b934a86aa Author: Hendrik Treutler Date: Mon Sep 5 12:48:59 2016 +0200 minor bug fix in unit test commit 1a69592b361794376eb01c28aaa263346acc449d Author: Hendrik Treutler Date: Mon Sep 5 12:40:52 2016 +0200 Bug fix in case of small m/z ranges from peak picking using centWave and bug fix regarding scantime ranges commit 8686fc16075ed7e2ca2b33f6c79e513b43cee92d Author: jotsetung Date: Mon Sep 5 10:51:11 2016 +0200 Update new_features vignette commit 7b72591f03fc429d408a89d1d4f8a92e3376ec10 Author: jotsetung Date: Mon Sep 5 09:59:35 2016 +0200 Add do_detectFeatures_centWave and doc updates o Export do_detectFeatures_centWave. o Add missing roxygen2 documentations. commit c70e5ba9edad767f6428ae441c2cba1d01de48e2 Author: jotsetung Date: Fri Sep 2 09:21:02 2016 +0200 Switch to do_detectFeatures_matchedFilter o findPeaks.matchedFilter calls do_detectFeatures_matchedFilter. o Default for now is to use the original code (discussed in issue #52). o Export useOriginalCode function that allows to switch between old and new implementation (default is old). o Describe discrepancies between old and new code for matchedFilter in the new_features.Rmd vignette. commit 2962d586d6505a6f09c53cf52117571f4b250a8e Author: jotsetung Date: Wed Aug 31 15:05:37 2016 +0200 Prepare all functions for issue #52 o Implement the test function comparing the matchedFilter implementations. o Start writing roxygen documentation for the do_ functions. o Tidy do_ functions up. commit 3ed5a6b9c7bae091a9ce84156bd06eadbf17df48 Author: Hendrik Treutler Date: Wed Aug 31 13:34:13 2016 +0200 Added standard generic commit 37f742eefd85a9e87a9b813516bbaa3b8d5f16ad Merge: efdbe68 71d4d46 Author: Hendrik Treutler Date: Wed Aug 31 09:40:24 2016 +0200 Merge branch 'devel' of https://github.com/Treutler/xcms into devel commit efdbe6828acc3281a907d0385d03b129cfa25f2c Author: htreutle Date: Wed Aug 31 09:14:38 2016 +0200 Added function findPeaks.centWaveWithPredictedIsotopeROIs for the sensitive detection of isotope peaks based on predicted isotope ROIs commit 1d3bb742ee0ea3e4f2b3739a59baf15574e1b1d3 Author: jotsetung Date: Mon Aug 29 12:30:49 2016 +0200 Add benchmarking vignette o Add benchmarking vignette. commit 7f78f064fa8397ecf2af0e9d9a30dac9fac0e37b Author: jotsetung Date: Thu Aug 25 06:25:16 2016 +0200 Fix compilation warnings in obiwarp code o Replace fabs with abs calls for integer variables in the C++ code of obiwarp that threw warnings during package compilation. commit 8f1b40a7d0aaaa51d8dcb709c8a78984445d8857 Author: jotsetung Date: Wed Aug 24 08:38:06 2016 +0200 Add new_functionality vignette o Add vignette describing new and modified functionality in xcms. commit 57b69a902c4cfd1f159c76760f6ab495f0ebb5b8 Author: jotsetung Date: Tue Aug 23 11:32:25 2016 +0200 Export binning functions o Export binYonX, breaks_on_binSize, breaks_on_nBins and imputeLinInterpol functions. o Add documenation (generated by roxygen2) for these functions. o Extensive unit tests for all functions. o Add parameter noInterpolAtEnds to imputeLinInterpol (mentioned in issue #49). commit fa1a0d5825c98ee939b23a3e993c359fe05f8ac3 Merge: 88ec298 71d4d46 Author: jotsetung Date: Tue Aug 23 08:29:33 2016 +0200 Merge branch 'devel' into xcms3 commit 88ec298cce23218ac20ed1c0dabeea73204aaa12 Author: jotsetung Date: Tue Aug 23 08:24:35 2016 +0200 Fix and improve binning functions o Fix breaks calculation for bins (multiplication instead of addition in C-function) resulting in identical break values than R's seq would. o Fix binYonX and imputeLinInterpol to return results identical to profBinM and similar (except bugs reported in issue #46). commit 71d4d46caab55d2eadcba535771d141bf4051837 Merge: 7f9bb05 7949102 Author: Steffen Neumann Date: Mon Aug 22 15:31:15 2016 +0200 Merge branch 'devel' of github.com:sneumann/xcms into devel commit 7f9bb0590b91346a41f2839f392d49eebfab8c34 Author: s.neumann Date: Mon Aug 22 13:30:24 2016 +0000 Temporarily disable vignette with benchmarking. git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@120327 bc3139a8-67e5-0310-9ffc-ced21a209358 commit b4f020db8c5f459d36db18574619c4e34e4e0b81 Author: s.neumann Date: Mon Aug 22 12:45:33 2016 +0000 updated NEWS and bumped version git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@120325 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 3625829bc0953c868f14598eec06512264ec8998 Merge: 100cedc 2fbba30 Author: s.neumann Date: Mon Aug 22 12:45:25 2016 +0000 Merge branch 'xcms3' into devel git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@120324 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 79491025c265337f65a1be98f662aae1f4569334 Merge: b17c615 5219078 Author: Steffen Neumann Date: Mon Aug 22 14:44:50 2016 +0200 fix whitespace merge conflict commit b17c615f7449a444931097a1c936b69fd1253646 Author: Steffen Neumann Date: Mon Aug 22 14:42:34 2016 +0200 updated NEWS and bumped version commit 5f57f336f7c8247a341d30c5314b959a1a4a0130 Merge: 100cedc 2fbba30 Author: Steffen Neumann Date: Mon Aug 22 14:37:09 2016 +0200 Merge branch 'xcms3' into devel commit 100cedc031a2e7b0b935d0d122b7ac5373b3db95 Merge: bc80d6a e429a1b Author: s.neumann Date: Mon Aug 22 12:19:25 2016 +0000 fix merge conflict in NEWS git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@120323 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 5219078a4cd3098395f081776599e52ba6769e68 Merge: bc80d6a e429a1b Author: Steffen Neumann Date: Mon Aug 22 14:18:49 2016 +0200 fix merge conflict in NEWS commit 2fbba3060dae40cd6c1fb625172fc4e68f9ef0e7 Author: jotsetung Date: Thu Aug 11 09:19:41 2016 +0200 Implement binlinbase missing value imputation o Separate binning and missing value imputation from profBin* methods into two functions: binYonX and imputeLinInterpol. o Unit tests to validate that results from profBin* methods and binYonX and imputeLinInterpol match. commit 77345695e4aaa9210723ccd083ed7d1f3b95f710 Author: jotsetung Date: Tue Aug 9 15:05:26 2016 +0200 Add unit test comparing profBinM o Unit test to compare profBinM with binYonX with support for multiple data sub-sets. commit 65d34ce811bd48774db10df922d0d6c90de5638c Author: jotsetung Date: Tue Aug 9 09:51:46 2016 +0200 Add functionality to binYonX o Add support for length(fromIdx) and length(toIdx) > 1: performs the binning for each individual sub-set and returns a list of results. o Add argument returnIndex, which allows to return the index of the max or min value within each bin in x. o Change behaviour of arguments fromX and toX. These are by default NA now and are calculated internally based on the (eventually sub-setted) x values. If provided they allow to manually force the bin-range to be the same for all potential sub-sets. o Update roxygen documentation, add unit tests. commit 379038a7c424bfd20aa85e203ae96e7c8fde4634 Author: jotsetung Date: Mon Aug 8 16:07:25 2016 +0200 Implement binlin imputation for binYonX o Implement the binlin imputation method for missing bin values in the binYonX function. o Add corresponding unit tests and benchmarks. commit c98934013ea9a8521972bf5ef07956130d375f6f Author: jotsetung Date: Mon Aug 8 09:42:08 2016 +0200 Unify binning functions into single C-function o Define a single C-level binning function as entry point from R: binYonX. o Fix logical & and | in C. o Add unit test for profBinLin; that fails due to the bug in profBinLin! o Extend some documentations. commit 900811d5f83825df3940e38f210ce901e9fe4a2f Author: jotsetung Date: Fri Aug 5 08:11:06 2016 +0200 Add matchedFilter do_ function o Implement do_detectFeatures_matchedFilter (issue #35); thus far containing the original code from findPeaks.matchedFilter. o Add tests to compare results for matchedFilter. commit 43c68cc7ca0374cfca6504ba2e6fd83f5a003ec3 Author: jotsetung Date: Thu Aug 4 14:43:58 2016 +0200 max, min, sum and mean for binning function o binYonX supports aggregation of values within bin using min, max, sum and mean. o Add corresponding unit tests. commit 36f612de00b42e7c39a434d24d739a2c2801db05 Author: jotsetung Date: Thu Aug 4 09:41:20 2016 +0200 Binning function allow to shift bins o Add argument to binning function to allow shifting bins by binSize/2 to simulate the profBin method (see also issue #42). o Add benchmarking vignette. commit 54218b5cfb44985ebfdeb473f5adca158bcaf171 Author: jotsetung Date: Thu Aug 4 07:51:46 2016 +0200 Binning funtions return bin mid-point o The C-level binning functions return the bin mid-point. o Add unit tests for binning functions. commit 1aa1165c12c1500458eac3203cc11aa0ef40dfa8 Merge: 75ca47a e429a1b Author: jotsetung Date: Tue Aug 2 10:00:59 2016 +0200 Merge branch 'devel' into xcms3 commit e429a1ba876b35cdf6a7e77a5c528be8f91fb3f7 Author: jotsetung Date: Tue Aug 2 09:54:28 2016 +0200 Fix getXcmsRaw bug reported by Aleksandr o Fix the bug in getXcmsRaw that would eventually not apply retention time correction when reading the raw data (issue #44). commit 75ca47a33adf11ed2bddf81d5fdc2b7445e7ad10 Author: jotsetung Date: Tue Aug 2 08:41:07 2016 +0200 Binning C-function about implemented o Add unit tests and write (not yet exported) documentation. commit 500509aa5851d41101485cee8dd33079e0d1f1e6 Merge: b67dc45 d8cddeb Author: jotsetung Date: Mon Aug 1 08:29:46 2016 +0200 Merge branch 'devel' of https://github.com/sneumann/xcms into devel commit b67dc45a54203a4acf529da5f32aaa35e143d128 Author: jotsetung Date: Mon Aug 1 08:27:55 2016 +0200 Address missing documentation warning. o Fix the missing [ documentation for xcmsSet (issue #43). o Fix two 'partial argument match' notes in R CMD check. commit 508c09507e5a0e5ac5e5df5ca7aba57501101163 Author: jotsetung Date: Mon Aug 1 07:52:16 2016 +0200 Prepare for C-level binning functions o Start implementing binning utilities in C. commit 0f5d3c423dfda64b825883d2f9e862799c10a78b Author: jotsetung Date: Thu Jul 28 13:41:32 2016 +0200 Some documentation updates. o Some updates that (hopefully) clarify the difference between getEIC and rawEIC. commit d8cddebcc8a62c304046e372ec59523d0d160b4f Merge: d7465f6 8e6439e Author: Steffen Neumann Date: Wed Jul 27 16:25:10 2016 +0200 Merge branch 'devel' of github.com:sneumann/xcms into devel commit b7d774bd919d8596342b228c69db7f6f58da14cf Author: jotsetung Date: Wed Jul 27 11:23:03 2016 +0200 Fix findmzROI. See issue #38 commit bc80d6ab546633b771d9a4b76553bd0eae617313 Author: s.neumann Date: Tue Jul 26 12:57:10 2016 +0000 Bump version From: Steffen Neumann git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@119638 bc3139a8-67e5-0310-9ffc-ced21a209358 commit d7465f657fc27b591976d16e7b173e24fc819209 Author: s.neumann Date: Tue Jul 26 12:57:10 2016 +0000 Bump version From: Steffen Neumann git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@119638 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 0976bd26e5defa62bf548a530eb16516325a71a3 Merge: acc52a4 e1d915d Author: s.neumann Date: Tue Jul 26 12:57:02 2016 +0000 Merge remote-tracking branch 'remotes/origin/devel' into devel From: Steffen Neumann git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@119637 bc3139a8-67e5-0310-9ffc-ced21a209358 commit a68d6cac8b51b42e94914e3e7b471dc2fa8560ed Author: s.neumann Date: Tue Jul 26 12:57:02 2016 +0000 Merge remote-tracking branch 'remotes/origin/devel' into devel From: Steffen Neumann git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@119637 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 8e6439e1a6b88df86c6c99c10ed309ab83f99ffb Author: Steffen Neumann Date: Tue Jul 26 14:55:54 2016 +0200 Bump version commit 3a40d763d105846c5b0cc235929fe0934c026269 Merge: acc52a4 e1d915d Author: Steffen Neumann Date: Tue Jul 26 10:50:47 2016 +0200 Merge remote-tracking branch 'remotes/origin/devel' into devel commit e1d915d74272b556e9ba61ad6455403ab8c75fea Author: jotsetung Date: Tue Jul 26 10:10:22 2016 +0200 Update NEWS file. commit ef488cf0cc03e8d2a323c14fb4286b2d08db14d6 Merge: f8aaddc 1fbabb9 Author: jotsetung Date: Tue Jul 26 09:53:19 2016 +0200 Merge branch 'xcms3' into devel commit f8aaddcae90146f34da495ea1472f33f18fb17f7 Author: jotsetung Date: Tue Jul 26 09:52:36 2016 +0200 Add readme.org to .gitignore commit e537216f5075f9739c9e851cfd08a9e4a8138ae3 Author: s.neumann Date: Tue Jul 26 07:16:21 2016 +0000 Use BiocParallel for parallel processing o Use bplapply in getXcmsRaw. o Deprecate xcmsPapply. o Update documentations to include BPPARAM argument. o Import from BiocGenerics and Biobase, remove the definitions of phenoData and phenoData<- generics. o Import from graphics, stats etc to fix 'R CMD check' warnings. git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@119633 bc3139a8-67e5-0310-9ffc-ced21a209358 commit c43e37a7890de080d4ce1b200695a6bbb979014a Author: s.neumann Date: Tue Jul 26 07:16:11 2016 +0000 findPeaks and fillPeaks using BiocParallel o Add xcmsSet2 function and fillPeaks.chrom2 method that use BiocParallel instead of manual parallel processing setup. o Add a unit test comparing the results. git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@119632 bc3139a8-67e5-0310-9ffc-ced21a209358 commit db566567149f571bcc459b10e5215324bef5fbc4 Author: s.neumann Date: Tue Jul 26 07:16:02 2016 +0000 Added some uncommitted mzTab stuff git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@119631 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 115d8fd7560b592fd963282fefb96adbf68b4c55 Author: s.neumann Date: Tue Jul 26 07:15:55 2016 +0000 fixed merge conflict git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@119630 bc3139a8-67e5-0310-9ffc-ced21a209358 commit c3bbb074a6817f6825dda2d740fc149a9f2c46f4 Merge: 55dfbb2 e81b590 Author: Steffen Neumann Date: Tue Jul 26 09:12:37 2016 +0200 Merge branch 'devel' of github.com:sneumann/xcms into devel commit 55dfbb2d639817b1f51bf4fabaa69281a1add4e3 Author: jotsetung Date: Mon Jul 18 14:41:57 2016 +0200 Use BiocParallel for parallel processing o Use bplapply in getXcmsRaw. o Deprecate xcmsPapply. o Update documentations to include BPPARAM argument. o Import from BiocGenerics and Biobase, remove the definitions of phenoData and phenoData<- generics. o Import from graphics, stats etc to fix 'R CMD check' warnings. commit 74d32385367baf7dcb0880486c6f2794e7c2f05a Author: jotsetung Date: Mon Jul 18 13:27:56 2016 +0200 findPeaks and fillPeaks using BiocParallel o Add xcmsSet2 function and fillPeaks.chrom2 method that use BiocParallel instead of manual parallel processing setup. o Add a unit test comparing the results. commit 7cd59c562406eecac77d15ed05bf9d4629c4a0a0 Author: Steffen Neumann Date: Tue May 17 00:20:39 2016 +0200 Added some uncommitted mzTab stuff commit 458fb021a0bf6d5ad3efd88da40475bae01ce8a3 Author: Steffen Neumann Date: Tue Jul 26 09:09:12 2016 +0200 fixed merge conflict commit 1fbabb9783ef3e144ab9a8dee3aaad6f505a24c9 Author: jotsetung Date: Mon Jul 25 15:17:28 2016 +0200 Add centWave do_function. + Implement the do_detectFeatures_centWave function. + Add unit test for do_detectFeatures_centWave. + Code reformatting. commit 72f8d6d69fb9b41f77ad6875a40766bbaa429b07 Author: jotsetung Date: Fri Jul 22 09:02:45 2016 +0200 Move packages from Suggests to Imports + Move packages multtest, MassSpecWavelet and RANN from DESCRIPTION's Suggests to Imports field (issue #34). + Fix warning message in findPeaksPar. commit 6da19f05041ab245f3cd83d04148c2d664b007f6 Author: jotsetung Date: Thu Jul 21 10:37:21 2016 +0200 Fix R CMD check warnings and notes (#32) + Move generics from CleanData.R to AllGenerics.R, methods to methods-xcmsRaw.R + Remove all DUP = FALSE from the .C calls as they are ignored anyways. + Fix bug in fillPeaksChromPar using an index i that does not exist. + Fix bug in fillPeaksChromPar referring to variable 'object' that does not exist. + Fix bug call in group.nearest to undefined variable coreList (change to scoreList). + Move all deprecated functions to Deprecated.R. commit 623c6fdc6700f894fbfb8fa192ba86e200234953 Author: jotsetung Date: Thu Jul 21 10:17:57 2016 +0200 Refactoring for xcmsEIC and xcmsFragments done. commit 09d92f2fc2c2b371c2fc496cf4de87802acdc9b9 Author: jotsetung Date: Thu Jul 21 09:36:08 2016 +0200 Refactor xcmsRaw R source files. + Split methods/functions for xcmsRaw into respective files. + Put all generics into AllGenerics.R commit 6cbe43599ae919b11bfee0de9b6887484c022c00 Author: jotsetung Date: Thu Jul 21 06:45:47 2016 +0200 Done with refactoring of xcmsSet R files + Moved all generic method definitions for xcmsSet and xcmsRaw into AllGenerics.R. + Moved all(?) xcmsSet methods into methods-xcmsSet.R. + Moved all xcmsSet functions into functions-xcmsSet.R. + Reverted the doRUnit.R file. commit a4d09a15aab9fc0e1d9d957ed5709d263d927c93 Author: jotsetung Date: Wed Jul 20 07:45:56 2016 +0200 Add updateObject method for xcmsSet + Add updateObject and validity method for xcmsSet along with corresponding unit tests. + Internal cleanup: move class definitions to DataClasses.R, use roxygen2 to create the Collate field in DESCRIPTION. commit e0d4e36a6db8ffd7a8d6c7753307cc39a33d2355 Merge: 55817bd e81b590 Author: jotsetung Date: Tue Jul 19 08:39:07 2016 +0200 Merge branch 'devel' into xcms3 commit e81b590fd2596829103798e5d8b19e2fdfde2018 Author: jotsetung Date: Mon Jul 18 14:41:57 2016 +0200 Use BiocParallel for parallel processing o Use bplapply in getXcmsRaw. o Deprecate xcmsPapply. o Update documentations to include BPPARAM argument. o Import from BiocGenerics and Biobase, remove the definitions of phenoData and phenoData<- generics. o Import from graphics, stats etc to fix 'R CMD check' warnings. commit c57175f33fc13bfed929530345145edcdcb1849a Author: jotsetung Date: Mon Jul 18 13:27:56 2016 +0200 findPeaks and fillPeaks using BiocParallel o Add xcmsSet2 function and fillPeaks.chrom2 method that use BiocParallel instead of manual parallel processing setup. o Add a unit test comparing the results. commit 55817bd32eb2bae345737d16a24883e527474347 Author: jotsetung Date: Mon Jul 18 13:27:56 2016 +0200 findPeaks and fillPeaks using BiocParallel o Add xcmsSet2 function and fillPeaks.chrom2 method that use BiocParallel instead of manual parallel processing setup. o Add a unit test comparing the results. commit e01074465062a674af92f0e2704073a11899dd1f Author: jotsetung Date: Mon Jul 18 09:04:01 2016 +0200 Add readme.org file. commit fcc1feb555bf6007b0ca2d37bc8f3b6635b40a9d Author: s.neumann Date: Tue May 17 07:41:19 2016 +0000 Add NEWS and bump version git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@117572 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 2c5e8aa4b2ec61dc9c3a121281625830c72879ff Author: s.neumann Date: Tue May 17 07:41:13 2016 +0000 Added some uncommitted mzTab stuff git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@117571 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 48931274f4fd638c8123ed01f10250f0b066f2e4 Author: s.neumann Date: Tue May 17 07:41:06 2016 +0000 First go at mzTab export git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@117570 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 0b11cc3eb8b0e879b2f4ba35c514eb71906b6f85 Author: Steffen Neumann Date: Tue May 17 07:37:54 2016 +0200 Add NEWS and bump version commit 9535218aaf8e52bcd361f1c912375854104e7e76 Author: Steffen Neumann Date: Tue May 17 00:20:39 2016 +0200 Added some uncommitted mzTab stuff commit 89ff2dbf642d5a786c8efc3bee0fcc9467933d15 Author: Steffen Neumann Date: Mon May 16 23:37:04 2016 +0200 First go at mzTab export commit f900b6144c5eb0bbf8ccf4faee5f691861270f1e Author: s.neumann Date: Sun May 15 21:30:54 2016 +0000 The raw CDF/mzXML/mzData/mzML is assumed to have scans sorted by m/z. Instead of throwing an "m/z sort assumption violated !" error, the data is re-read and on-demand sorted by m/z. git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@117517 bc3139a8-67e5-0310-9ffc-ced21a209358 commit 7b38c2d610f66a1fee9d9330119f2b9c04fdf20e Merge: 23c01d7 f9be4f4 Author: s.neumann Date: Sun May 15 21:30:46 2016 +0000 Merge branch 'fixmzsortassumption' into devel git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@117516 bc3139a8-67e5-0310-9ffc-ced21a209358 commit f9be4f4f23c49f56074670658bc9665e093c8f83 Author: Steffen Neumann Date: Fri Apr 1 14:09:29 2016 +0200 Add automatic repair for "m/z sort assumption violated !" error in findPeaks (centWave) From: Steffen Neumann git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/xcms@131862 bc3139a8-67e5-0310-9ffc-ced21a209358 --- DESCRIPTION | 4 +- NAMESPACE | 11 +- R/DataClasses.R | 118 +++++++++++- R/do_groupChromPeaks-functions.R | 3 +- R/functions-OnDiskMSnExp.R | 9 +- R/functions-Params.R | 31 +++ R/functions-XCMSnExp.R | 184 +++++++++++++----- R/functions-normalization.R | 6 +- R/functions-xcmsSet.R | 19 ++ R/matchpeaks.R | 271 +++++++++++++++++++++++---- R/methods-MsFeatureData.R | 33 ++-- R/methods-XCMSnExp.R | 123 +++++++++++- R/methods-xcmsSet.R | 177 +++++++++++------ inst/NEWS | 26 +++ inst/unitTests/runit.Param-classes.R | 25 ++- inst/unitTests/runit.XCMSnExp.R | 27 +++ inst/unitTests/runit.calibrate.R | 67 +++++++ inst/unitTests/runit.matchpeaks.R | 92 +++++++++ inst/unitTests/runit.xcmsSet.R | 8 + man/XCMSnExp-class.Rd | 11 +- man/calibrate-calibrant-mass.Rd | 95 ++++++++++ man/phenoDataFromPaths.Rd | 27 +++ man/plotChromPeakDensity.Rd | 64 ++++--- vignettes/new_functionality.org | 32 ++++ vignettes/xcms-direct-injection.Rmd | 242 ++++++++++++++++++++++++ vignettes/xcmsDirect.Rnw | 187 ------------------ vignettes/xcmsInstall.Rnw | 203 -------------------- 27 files changed, 1494 insertions(+), 601 deletions(-) create mode 100644 inst/unitTests/runit.calibrate.R create mode 100644 inst/unitTests/runit.matchpeaks.R create mode 100644 man/calibrate-calibrant-mass.Rd create mode 100644 man/phenoDataFromPaths.Rd create mode 100644 vignettes/xcms-direct-injection.Rmd delete mode 100644 vignettes/xcmsDirect.Rnw delete mode 100644 vignettes/xcmsInstall.Rnw diff --git a/DESCRIPTION b/DESCRIPTION index adfde7243..08d285d4a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: xcms -Version: 2.99.5 -Date: 2017-07-14 +Version: 2.99.6 +Date: 2017-08-09 Title: LC/MS and GC/MS Data Analysis Author: Colin A. Smith , Ralf Tautenhahn , diff --git a/NAMESPACE b/NAMESPACE index 9cbb81481..38863488d 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -69,7 +69,8 @@ export( "xcmsRaw", "xcmsSet", "xcmsFragments", - "xcmsPapply" + "xcmsPapply", + "phenoDataFromPaths" ) S3method(plot, xcmsEIC) @@ -212,7 +213,8 @@ export( "highlightChromPeaks", "plotChromPeakDensity", "plotChromPeaks", - "plotChromPeakImage" + "plotChromPeakImage", + "isCalibrated" ) ## New analysis methods @@ -236,7 +238,8 @@ exportClasses( "PeakGroupsParam", "ObiwarpParam", "GenericParam", - "FillChromPeaksParam" + "FillChromPeaksParam", + "CalibrantMassParam" ) ## Param methods exportMethods( @@ -386,7 +389,7 @@ exportMethods( export("CentWaveParam", "MatchedFilterParam", "MassifquantParam", "MSWParam", "CentWavePredIsoParam", "PeakDensityParam", "MzClustParam", "NearestPeaksParam", "PeakGroupsParam", "ObiwarpParam", "GenericParam", - "FillChromPeaksParam") + "FillChromPeaksParam", "CalibrantMassParam") ## Param class methods. ## New Classes diff --git a/R/DataClasses.R b/R/DataClasses.R index 89359fcfb..719de098d 100644 --- a/R/DataClasses.R +++ b/R/DataClasses.R @@ -187,12 +187,14 @@ setClass("xcmsPeaks", contains = "matrix") .PROCSTEP.PEAK.GROUPING <- "Peak grouping" .PROCSTEP.RTIME.CORRECTION <- "Retention time correction" .PROCSTEP.PEAK.FILLING <- "Missing peak filling" +.PROCSTEP.CALIBRATION <- "Calibration" .PROCSTEPS <- c( .PROCSTEP.UNKNOWN, .PROCSTEP.PEAK.DETECTION, .PROCSTEP.PEAK.GROUPING, .PROCSTEP.RTIME.CORRECTION, - .PROCSTEP.PEAK.FILLING + .PROCSTEP.PEAK.FILLING, + .PROCSTEP.CALIBRATION ) ############################################################ @@ -2405,3 +2407,117 @@ setClass("XCMSnExp", } ) +#' @aliases mz,CalibrantMassParam +#' +#' @title Calibrant mass based calibration of chromatgraphic peaks +#' +#' @description Calibrate peaks using mz values of known masses/calibrants. +#' mz values of identified peaks are adjusted based on peaks that are close +#' to the provided mz values. See details below for more information. +#' +#' @param mz a `numeric` or `list` of `numeric` vectors with reference mz +#' values. If a `numeric` vector is provided, this is used for each sample +#' in the `XCMSnExp` object. If a `list` is provided, it's length has to be +#' equal to the number of samples in the experiment. +#' +#' @param mzabs `numeric(1)` the absolute error/deviation for matching peaks to +#' calibrants (in Da). +#' +#' @param mzppm `numeric(1)` the relative error for matching peaks to calibrants +#' in ppm (parts per million). +#' +#' @param neighbors `integer(1)` with the maximal number of peaks within the +#' permitted distance to the calibrants that are considered. Among these the +#' mz value of the peak with the largest intensity is used in the +#' calibration function estimation. +#' +#' @param method `character(1)` defining the method that should be used to +#' estimate the calibration function. Can be `"shift"`, `"linear"` (default) +#' or `"edgeshift"`. +#' +#' @details The method does first identify peaks that are close to the provided +#' mz values and, given that there difference to the calibrants is smaller +#' than the user provided cut off (based on arguments `mzabs` and `mzppm`), +#' their mz values are replaced with the provided mz values. The mz values +#' of all other peaks are either globally shifted (for `method = "shift"` +#' or estimated by a linear model through all calibrants. +#' Peaks are considered close to a calibrant mz if the difference between +#' the calibrant and its mz is `<= mzabs + mz * mzppm /1e6`. +#' +#' **Adjustment methods**: adjustment function/factor is estimated using +#' the difference between calibrant and peak mz values only for peaks +#' that are close enough to the calibrants. The availabel methods are: +#' * `shift`: shifts the m/z of each peak by a global factor which +#' corresponds to the average difference between peak mz and calibrant mz. +#' * `linear`: fits a linear model throught the differences between +#' calibrant and peak mz values and adjusts the mz values of all peaks +#' using this. +#' * `edgeshift`: performs same adjustment as `linear` for peaks that are +#' within the mz range of the calibrants and shift outside of it. +#' +#' For more information, details and examples refer to the +#' *xcms-direct-injection* vignette. +#' +#' @note `CalibrantMassParam` classes don't have exported getter or setter +#' methods. +#' +#' @return For `CalibrantMassParam`: a `CalibrantMassParam` instance. +#' For `calibrate`: an [XCMSnExp] object with chromatographic peaks being +#' calibrated. **Be aware** that the actual raw mz values are not (yet) +#' calibrated, but **only** the identified chromatographic peaks. +#' +#' @author Joachim Bargsten, Johannes Rainer +#' +#' @md +#' +#' @rdname calibrate-calibrant-mass +setClass("CalibrantMassParam", + slots = c( + mz = "list", + mzabs = "numeric", + mzppm = "numeric", + neighbors = "integer", + method = "character" + ), + contains = c("Param"), + prototype = prototype( + mz = list(), + mzabs = 0.0001, + mzppm = 5, + neighbors = 3L, + method = "linear" + ), + validity = function(object) { + msg <- character() + if (length(object@mz)) { + is_num <- vapply(object@mz, FUN = is.numeric, + FUN.VALUE = logical(1), USE.NAMES = FALSE) + if (any(!is_num)) + msg <- c(msg, paste0("'mz' has to be a list of numeric", + " vectors")) + is_unsorted <- vapply(object@mz, FUN = is.unsorted, + FUN.VALUE = logical(1), + USE.NAMES = FALSE) + if (any(is_unsorted)) + msg <- c(msg, paste0("the mz values in 'mz' have to be ", + "increasingly ordered")) + } + if (length(object@mzppm) != 1 | any(object@mzppm < 0)) + msg <- c(msg, paste0("'mzppm' has to be positive numeric", + " of length 1.")) + if (length(object@mzabs) != 1 | any(object@mzabs < 0)) + msg <- c(msg, paste0("'mzabs' has to be positive numeric", + " of length 1.")) + if (length(object@neighbors) != 1 | any(object@neighbors <= 0)) + msg <- c(msg, paste0("'neighbors' has to be positive integer", + " of length 1.")) + if (length(object@method) != 1) + msg <- c(msg, paste0("'method' has to be of length 1.")) + if (!all(object@method %in% c("linear", "shift", "edgeshift"))) + msg <- c(msg, paste0("'method' should be one of 'linear'", + ", 'shift' or 'edgeshift'.")) + if (length(msg)) + msg + else + TRUE + }) diff --git a/R/do_groupChromPeaks-functions.R b/R/do_groupChromPeaks-functions.R index 930fd065c..d87c101d0 100644 --- a/R/do_groupChromPeaks-functions.R +++ b/R/do_groupChromPeaks-functions.R @@ -120,7 +120,8 @@ do_groupChromPeaks_density <- function(peaks, sampleGroups, densFrom <- rtRange[1] - 3 * bw densTo <- rtRange[2] + 3 * bw - densN <- max(512, 2^(ceiling(log2(diff(rtRange) / (bw / 2))))) + ## Increase the number of sampling points for the density distribution. + densN <- max(512, 2 * 2^(ceiling(log2(diff(rtRange) / (bw / 2))))) endIdx <- 0 num <- 0 gcount <- integer(nSampleGroups) diff --git a/R/functions-OnDiskMSnExp.R b/R/functions-OnDiskMSnExp.R index a5ea487f6..d0a1deb56 100644 --- a/R/functions-OnDiskMSnExp.R +++ b/R/functions-OnDiskMSnExp.R @@ -54,12 +54,13 @@ findChromPeaks_Spectrum_list <- function(x, method = "centWave", param, rt) { if (is.unsorted(rt)) stop("Spectra are not ordered by retention time!") mzs <- lapply(x, mz) + vals_per_spect <- lengths(mzs, FALSE) procDat <- date() res <- do.call(method, args = c(list(mz = unlist(mzs, use.names = FALSE), int = unlist(lapply(x, intensity), use.names = FALSE), - valsPerSpect = lengths(mzs, FALSE), + valsPerSpect = vals_per_spect, scantime = rt), as(param, "list"))) ## Ensure that we call the garbage collector to eventually clean unused stuff @@ -301,8 +302,10 @@ findPeaks_MSW_Spectrum_list <- function(x, method = "MSW", param) { mzvals <- length(mzs) cntrVals <- length(cntrPr$profMat) curVals <- length(curP$profMat) - if ((mzvals * valscantime1) != cntrVals | (mzvals * valscantime2) != curVals - | cntrVals != curVals) + if ((mzvals * valscantime1) != cntrVals | (mzvals * valscantime2) != curVals) + ## Here the question is if we REALLY need to have the same numbers + ## of values in both. This caused the problems in issue #196 + ## | cntrVals != curVals) stop("Dimensions of profile matrices of files ", basename(fileNames(cntr)), " and ", basename(fileNames(z)), " do not match!") diff --git a/R/functions-Params.R b/R/functions-Params.R index 6ea734c77..8d581f7b8 100644 --- a/R/functions-Params.R +++ b/R/functions-Params.R @@ -301,3 +301,34 @@ FillChromPeaksParam <- function(expandMz = 0, expandRt = 0, ppm = 0) { return(new("FillChromPeaksParam", expandMz = expandMz, expandRt = expandRt, ppm = ppm)) } + + +#' @return The `CalibrantMassParam` function returns an instance of +#' the `CalibrantMassParam` class with all settings and properties set. +#' +#' @md +#' +#' @rdname calibrate-calibrant-mass +CalibrantMassParam <- function(mz = list(), mzabs = 0.0001, mzppm = 5, + neighbors = 3, method = "linear") { + if (!is.list(mz)) + mz <- list(mz) + mz <- lapply(mz, sort) + new("CalibrantMassParam", mz = mz, mzabs = mzabs, mzppm = mzppm, + neighbors = as.integer(neighbors), method = method) +} + +.mzabs <- function(x) + x@mzabs + +.mzppm <- function(x) + x@mzppm + +.neighbors <- function(x) + x@neighbors + +.method <- function(x) + x@method + +.mz <- function(x) + x@mz diff --git a/R/functions-XCMSnExp.R b/R/functions-XCMSnExp.R index bb56a23ba..69e2984ca 100644 --- a/R/functions-XCMSnExp.R +++ b/R/functions-XCMSnExp.R @@ -992,56 +992,74 @@ plotAdjustedRtime <- function(object, col = "#00000080", lty = 1, type = "l", #' @title Plot chromatographic peak density along the retention time axis #' #' @description Plot the density of chromatographic peaks along the retention -#' time axis and indicate which peaks would be grouped into the same feature -#' based using the \emph{peak density} correspondence method. Settings for -#' the \emph{peak density} method can be passed with an -#' \code{\link{PeakDensityParam}} object to parameter \code{param}. -#' -#' @details The \code{plotChromPeakDensity} function allows to evaluate -#' different settings for the \emph{peak density} on an mz slice of +#' time axis and indicate which peaks would be (or were) grouped into the +#' same feature based using the *peak density* correspondence method. +#' Settings for the *peak density* method can be passed with an +#' [PeakDensityParam] object to parameter `param`. If the `object` contains +#' correspondence results and the correspondence was performed with the +#' *peak groups* method, the results from that correspondence can be +#' visualized setting `simulate = FALSE`. +#' +#' @details The `plotChromPeakDensity` function allows to evaluate +#' different settings for the *peak density* on an mz slice of #' interest (e.g. containing chromatographic peaks corresponding to a known #' metabolite). #' The plot shows the individual peaks that were detected within the -#' specified \code{mz} slice at their retention time (x-axis) and sample in +#' specified `mz` slice at their retention time (x-axis) and sample in #' which they were detected (y-axis). The density function is plotted as a -#' black line. Parameters for the \code{density} function are taken from the -#' \code{param} object. Grey rectangles indicate which chromatographic peaks -#' would be grouped into a feature by the \emph{peak density} correspondence -#' method. Parameters for the algorithm are also taken from \code{param}. -#' See \code{\link{groupChromPeaks-density}} for more information about the +#' black line. Parameters for the `density` function are taken from the +#' `param` object. Grey rectangles indicate which chromatographic peaks +#' would be grouped into a feature by the `peak density` correspondence +#' method. Parameters for the algorithm are also taken from `param`. +#' See [groupChromPeaks-density()] for more information about the #' algorithm and its supported settings. #' -#' @param object A \code{\link{XCMSnExp}} object with identified +#' @param object A [XCMSnExp] object with identified #' chromatographic peaks. #' -#' @param mz \code{numeric(2)} defining an mz range for which the peak density +#' @param mz `numeric(2)` defining an mz range for which the peak density #' should be plotted. #' -#' @param rt \code{numeric(2)} defining an optional rt range for which the +#' @param rt `numeric(2)` defining an optional rt range for which the #' peak density should be plotted. Defaults to the absolute retention time -#' range of \code{object}. +#' range of `object`. #' -#' @param param \code{\link{PeakDensityParam}} from which parameters for the -#' \emph{peak density} correspondence algorithm can be extracted. +#' @param param [PeakDensityParam] from which parameters for the +#' *peak density* correspondence algorithm can be extracted. If not provided +#' and if `object` contains feature definitions with the correspondence/ +#' peak grouping being performed by the *peak density* method, the +#' corresponding parameter class stored in `object` is used. +#' +#' @param simulate `logical(1)` defining whether correspondence should be +#' simulated within the specified m/z / rt region or (with +#' `simulate = FALSE`) whether the results from an already performed +#' correspondence should be shown. #' #' @param col Color to be used for the individual samples. Length has to be 1 -#' or equal to the number of samples in \code{object}. +#' or equal to the number of samples in `object`. +#' +#' @param xlab `character(1)` with the label for the x-axis. #' -#' @param xlab \code{character(1)} with the label for the x-axis. +#' @param ylab `character(1)` with the label for the y-axis. #' -#' @param ylab \code{character(1)} with the label for the y-axis. +#' @param xlim `numeric(2)` representing the limits for the x-axis. +#' Defaults to the range of the `rt` parameter. #' -#' @param xlim \code{numeric(2)} representing the limits for the x-axis. -#' Defaults to the range of the \code{rt} parameter. +#' @param main `character(1)` defining the title of the plot. By default +#' (for `main = NULL`) the mz-range is used. #' -#' @param ... Additional parameters to be passed to the \code{plot} function. +#' @param ... Additional parameters to be passed to the `plot` function. Data +#' point specific parameters such as `bg` or `pch` have to be of length 1 +#' or equal to the number of samples. #' #' @return The function is called for its side effect, i.e. to create a plot. #' #' @author Johannes Rainer #' -#' @seealso \code{\link{groupChromPeaks-density}} for details on the -#' \emph{peak density} correspondence method and supported settings. +#' @seealso [groupChromPeaks-density()] for details on the +#' *peak density* correspondence method and supported settings. +#' +#' @md #' #' @examples #' @@ -1076,9 +1094,10 @@ plotAdjustedRtime <- function(object, col = "#00000080", lty = 1, type = "l", #' ## Require the chromatographic peak to be present in all samples of a group #' plotChromPeakDensity(res, mz = mzr, pch = 16, #' param = PeakDensityParam(minFraction = 1)) -plotChromPeakDensity <- function(object, mz, rt, param = PeakDensityParam(), +plotChromPeakDensity <- function(object, mz, rt, param, simulate = TRUE, col = "#00000080", xlab = "retention time", - ylab = "sample", xlim = range(rt), ...) { + ylab = "sample", xlim = range(rt), + main = NULL, ...) { if (missing(object)) stop("Required parameter 'object' is missing") if (!is(object, "XCMSnExp")) @@ -1089,6 +1108,22 @@ plotChromPeakDensity <- function(object, mz, rt, param = PeakDensityParam(), mz <- c(-Inf, Inf) if (missing(rt)) rt <- range(rtime(object)) + if (!simulate & !hasFeatures(object)) { + warning("Falling back to 'simulate = TRUE' because no correspondence ", + "results are present") + simulate <- TRUE + } + if (missing(param)) { + ## Use the internal parameter - if available. + if (hasFeatures(object)) { + ph <- processHistory(object, type = .PROCSTEP.PEAK.GROUPING) + param <- processParam(ph[[length(ph)]]) + } else { + param = PeakDensityParam() + } + } + if (!is(param, "PeakDensityParam")) + stop("'param' has to be a 'PeakDensityParam'") mz <- range(mz) rt <- range(rt) ## Get all the data we require. @@ -1099,8 +1134,13 @@ plotChromPeakDensity <- function(object, mz, rt, param = PeakDensityParam(), if (nrow(pks)) { ## Extract parameters from the param object bw = bw(param) + ## Ensure the density is calculated exactly as it would in the real + ## case. + full_rt_range <- range(chromPeaks(object)[, "rt"]) + dens_from <- full_rt_range[1] - 3 * bw + dens_to <- full_rt_range[2] + 3 * bw ## That's Jan Stanstrup's fix (issue #161). - densN <- max(512, 2^(ceiling(log2(diff(rt) / (bw / 2))))) + densN <- max(512, 2 * 2^(ceiling(log2(diff(full_rt_range) / (bw / 2))))) sample_groups <- sampleGroups(param) if (length(sample_groups) == 0) sample_groups <- rep(1, nsamples) @@ -1109,38 +1149,66 @@ plotChromPeakDensity <- function(object, mz, rt, param = PeakDensityParam(), "class has to have the same length than there are samples ", "in 'object'") sample_groups_table <- table(sample_groups) - dens_from <- rt[1] - 3 * bw - dens_to <- rt[2] + 3 * bw dens <- density(pks[, "rt"], bw = bw, from = dens_from, to = dens_to, n = densN) yl <- c(0, max(dens$y)) - ypos <- seq(from = 0, to = yl[2], length.out = nsamples) + ypos <- seq(from = yl[1], to = yl[2], length.out = nsamples) + if (is.null(main)) + main <- paste0(format(mz, digits = 7), collapse = " - ") ## Plot the peaks as points. - plot(x = pks[, "rt"], y = ypos[pks[, "sample"]], xlim = xlim, - col = col[pks[, "sample"]], xlab = xlab, yaxt = "n", ylab = ylab, - main = paste0(format(mz, digits = 7), collapse = " - "), ylim = yl, - ...) + ## Fix assignment of point types for each sample. + dots <- list(...) + if (any(names(dots) == "bg")) { + bg <- dots$bg + if (length(bg) != nsamples) + bg <- rep_len(bg[1], nsamples) + dots$bg <- bg[pks[, "sample"]] + } + if (any(names(dots) == "pch")) { + pch <- dots$pch + if (length(pch) != nsamples) + pch <- rep_len(pch[1], nsamples) + dots$pch <- pch[pks[, "sample"]] + } + do.call("plot", args = c(list(x = pks[, "rt"], + y = ypos[pks[, "sample"]], xlim = xlim, + col = col[pks[, "sample"]], xlab = xlab, + yaxt = "n", ylab = ylab, + main = main, ylim = yl), dots)) + ## plot(x = pks[, "rt"], y = ypos[pks[, "sample"]], xlim = xlim, + ## col = col[pks[, "sample"]], xlab = xlab, yaxt = "n", ylab = ylab, + ## main = main, ylim = yl, + ## ...) axis(side = 2, at = ypos, labels = 1:nsamples) points(x = dens$x, y = dens$y, type = "l") ## Estimate what would be combined to a feature ## Code is taken from do_groupChromPeaks_density dens_max <- max(dens$y) dens_y <- dens$y - snum <- 0 - while(dens_y[max_y <- which.max(dens_y)] > dens_max / 20 && - snum < maxFeatures(param)) { - feat_range <- xcms:::descendMin(dens_y, max_y) - dens_y[feat_range[1]:feat_range[2]] <- 0 - feat_idx <- which(pks[, "rt"] >= dens$x[feat_range[1]] & - pks[, "rt"] <= dens$x[feat_range[2]]) - tt <- table(sample_groups[pks[feat_idx, "sample"]]) - if (!any(tt / sample_groups_table[names(tt)] >= - minFraction(param) & tt >= minSamples(param))) - next - rect(xleft = min(pks[feat_idx, "rt"]), ybottom = 0, - xright = max(pks[feat_idx, "rt"]), ytop = yl[2], - border = "#00000040", col = "#00000020") - } + if (simulate) { + snum <- 0 + while(dens_y[max_y <- which.max(dens_y)] > dens_max / 20 && + snum < maxFeatures(param)) { + feat_range <- descendMin(dens_y, max_y) + dens_y[feat_range[1]:feat_range[2]] <- 0 + feat_idx <- which(pks[, "rt"] >= dens$x[feat_range[1]] & + pks[, "rt"] <= dens$x[feat_range[2]]) + tt <- table(sample_groups[pks[feat_idx, "sample"]]) + if (!any(tt / sample_groups_table[names(tt)] >= + minFraction(param) & tt >= minSamples(param))) + next + rect(xleft = min(pks[feat_idx, "rt"]), ybottom = yl[1], + xright = max(pks[feat_idx, "rt"]), ytop = yl[2], + border = "#00000040", col = "#00000020") + } + } else { + ## Plot all features in the region. + fts <- featureDefinitions(object, mz = mz, rt = rt) + rect(xleft = fts$rtmin, xright = fts$rtmax, + ybottom = rep(yl[1], nrow(fts)), ytop = rep(yl[2], nrow(fts)), + border = "#00000040", col = "#00000020") + abline(v = fts$rtmed, col = "#00000040", lty = 2) + } } else { plot(3, 3, pch = NA, xlim = rt, xlab = xlab, main = paste0(format(mz, digits = 7), collapse = " - ")) @@ -1413,6 +1481,18 @@ plotChromPeakImage <- function(x, binSize = 30, xlim = NULL, log = FALSE, } } +#' @rdname calibrate-calibrant-mass +#' +#' @description The `isCalibrated` function returns `TRUE` if chromatographic +#' peaks of the [XCMSnExp] object `x` were calibrated and `FALSE` otherwise. +#' +#' @md +isCalibrated <- function(object) { + if (length(processHistory(object, type = .PROCSTEP.CALIBRATION))) + TRUE + else + FALSE +} ## Find mz ranges with multiple peaks per sample. ## Use the density distribution for that? with a bandwidth = 0.001, check diff --git a/R/functions-normalization.R b/R/functions-normalization.R index e32a04b1b..d4acab811 100644 --- a/R/functions-normalization.R +++ b/R/functions-normalization.R @@ -192,9 +192,9 @@ adjustDriftWithModel <- function(y, data = NULL, model = y ~ injection_idx, data_fit <- data_fit[fitOnSubset, , drop = FALSE] ## First fitting the model. message("Fitting the model to the features ... ", appendLF = FALSE) - lms <- xcms:::fitModel(formula = model, data = data_fit, - y = y[, fitOnSubset, drop = FALSE], - minVals = minVals, method = method) + lms <- fitModel(formula = model, data = data_fit, + y = y[, fitOnSubset, drop = FALSE], + minVals = minVals, method = method) message("OK") message("Applying models to adjust values ... ", appendLF = FALSE) if (is.null(rownames(y))) diff --git a/R/functions-xcmsSet.R b/R/functions-xcmsSet.R index aba8d0b8b..19e3e47e3 100644 --- a/R/functions-xcmsSet.R +++ b/R/functions-xcmsSet.R @@ -365,6 +365,25 @@ split.xcmsSet <- function(x, f, drop = TRUE, ...) { ############################################################ ## phenoDataFromPaths ## derive experimental design from set of file paths +#' @title Derive experimental design from file paths +#' +#' @description The `phenoDataFromPaths` function builds a `data.frame` +#' representing the experimental design from the folder structure in which +#' the files of the experiment are located. +#' +#' @note This function is used by the *old* `xcmsSet` function to guess +#' the experimental design (i.e. group assignment of the files) from the +#' folders in which the files of the experiment can be found. +#' +#' @param paths `character` representing the file names (including the full +#' path) of the experiment's files. +#' +#' @md +#' +#' @examples +#' ## List the files available in the faahKO package +#' base_dir <- system.file("cdf", package = "faahKO") +#' cdf_files <- list.files(base_dir, recursive = TRUE, full.names = TRUE) phenoDataFromPaths <- function(paths) { ## create factors from filesystem hierarchy sclass <- gsub("^\\.$", "sample", dirname(paths)) diff --git a/R/matchpeaks.R b/R/matchpeaks.R index 41dbcc712..a2eb1b2d4 100644 --- a/R/matchpeaks.R +++ b/R/matchpeaks.R @@ -1,25 +1,72 @@ -matchpeaks <- function(peaklist, masslist, mzabs=0.0001, mzppm=5, neighbours=3, intensity="into"){ +#' @title Identify peaks close to calibrants' mz values +#' +#' @description Define which peaks are closest to the provided calibrants' mz +#' values and return their index, mz value and difference between their and +#' the calibrant's mz value. +#' +#' @note The mz values of the calibrants are first sorted. *Cave* the function +#' requires the `peaklist` to be sorted by mz value (issue #200). +#' +#' @param peaklist `matrix` with the identified peaks of a single sample. +#' Required columns are: `"mz"` and `intensity` +#' +#' @param masslist `numeric` with the masses of the calibrants. +#' +#' @param mzabs `numeric(1)` defining the absolute mz deviation. +#' +#' @param mzppm `numeric(1)` defining the mz deviation in ppm. +#' +#' @param neighbours `numeric(1)` with the number of neighbors. +#' +#' @param intensity `character(1)` specifying the column in `peaklist` that +#' contains the peaks' intensity values. +#' +#' @return A `matrix` with 3 columns: +#' + `"pos"`: the position of the peak closest to the corresponding +#' calibrant's mz value. +#' + `"mass"`: the m/z of the peak. +#' + `"dif"`: the difference between the calibrant's and peak's mz. +#' The number of rows corresponds to the number of calibrants, unless no +#' peak was found to be close enough to a calibrant. In the latter case +#' the calibrant is removed from the result table. +#' +#' @md +#' +#' @noRd +matchpeaks <- function(peaklist, masslist, mzabs = 0.0001, mzppm = 5, + neighbours = 3, intensity = "into") { + ## Dangerous, we're nowhere checking for masslist being correct. masslist <- masslist[order(masslist)] - dif <- matrix(nrow=length(masslist), ncol=neighbours, data=rep(1000,length(masslist)*neighbours)) - pos <- matrix(nrow=length(masslist), ncol=neighbours, data=rep(0,length(masslist)*neighbours)) - mzu <- peaklist[,"mz"] - itu <- peaklist[,intensity] - mdif <- NA - mpos <- NA + dif <- matrix(nrow = length(masslist), ncol = neighbours, + data = rep(1000, length(masslist) * neighbours)) + pos <- matrix(nrow = length(masslist), ncol = neighbours, + data = rep(0, length(masslist) * neighbours)) + mzu <- peaklist[, "mz"] + itu <- peaklist[, intensity] + mdif <- NA ## smallest difference between a peak and a calibrant. + mpos <- NA ## position of the entry in the peak list. cdifs <- NA cposs <- NA - lastval<-1 + lastval <- 1 + ## Loop over masslist. for (b in 1:length(masslist)){ - ## finding for each entry in masslist the ##neighbours closest masses in the spectra + ## finding for each entry in masslist the ##neighbours closest masses + ## in the peaklist a <- lastval - sf <- FALSE ## is set to true if the neighbour-box is filled the first time for a entry in masslist + sf <- FALSE ## is set to true if the neighbour-box is filled the first + ## time for a entry in masslist while (a < length(mzu)){ - mxd <- dif[b,max(which(abs(dif[b,])==max(abs(dif[b,]))))] ## the currently biggest distance - mxp <- max(which(abs(dif[b,])==max(abs(dif[b,])))) ## the position of the distance - if (abs(mzu[a]-masslist[b]) <= abs(mxd)){ - dif[b,mxp] <- (mzu[a]-masslist[b]) - pos[b,mxp] <- a - lastval <- min(pos[b,]) + ## loop over peaks + ## the currently biggest distance: + mxd <- dif[b, max(which(abs(dif[b, ]) == max(abs(dif[b,]))))] + ## the position of the distance + mxp <- max(which(abs(dif[b, ]) == max(abs(dif[b,])))) + ## If the difference between the peak and the current mass is + ## smaller than the largest difference in dif + if (abs(mzu[a] - masslist[b]) <= abs(mxd)) { + dif[b, mxp] <- (mzu[a] - masslist[b]) + pos[b, mxp] <- a + lastval <- min(pos[b, ]) sf <- TRUE }else{ ## no more masses are smaller, switching to end of mzu if (sf) a <- length(mzu) @@ -27,40 +74,196 @@ matchpeaks <- function(peaklist, masslist, mzabs=0.0001, mzppm=5, neighbours=3, a <- a + 1 } ## cat(min(abs(dif[b,])),"\n") - ## checking the treshold and finding the candidate with the biggest intensity - smalldiffs <- which(abs(dif[b,]) <= (mzabs+(mzu[pos[b,]]/1000000*mzppm))) - cdifs <- dif[b,smalldiffs] - cposs <- pos[b,smalldiffs] - if (length(cdifs)>0){ + ## checking the treshold and finding the candidate with the biggest + ## intensity + smalldiffs <- which(abs(dif[b, ]) <= + (mzabs + (mzu[pos[b, ]] / 1000000 * mzppm))) + cdifs <- dif[b, smalldiffs] + cposs <- pos[b, smalldiffs] + if (length(cdifs) > 0){ mcdi <- smalldiffs[which(itu[cposs] == max(itu[cposs]))] - mdif[b] <- dif[b,mcdi] - mpos[b] <- pos[b,mcdi] + mdif[b] <- dif[b, mcdi] ## mz - mz_masslist + mpos[b] <- pos[b, mcdi] ## The index of the mz in the peaklist. }else{ - mdif[b]<-NA - mpos[b]<-NA + ## No peak close. + mdif[b] <- NA + mpos[b] <- NA } } mdiffs <- mdif[!is.na(mdif)] mposs <- mpos[!is.na(mdif)] - retdata <- matrix(ncol=3, nrow=length(mdiffs), data=c(mposs,mzu[mposs],mdiffs)) - colnames(retdata) = c("pos","mass","dif") + retdata <- matrix(ncol = 3, nrow = length(mdiffs), + data = c(mposs, mzu[mposs], mdiffs)) + colnames(retdata) = c("pos", "mass", "dif") retdata } -estimate <- function(dtable,method="linear"){ - mdiffs <- dtable[,"dif"] - mposs <- dtable[,"mass"] +#' @title Identify peaks close to calibrants' mz values +#' +#' @description Define which peaks are closest to the provided calibrants' mz +#' values and return their index, mz value and difference between their and +#' the calibrant's mz value. +#' +#' @details This function is faster than the original `matchpeaks` function and +#' in addition does by default return the results for all calibrants' mz +#' values, i.e. `nrow` of the result `matrix` is always equal to +#' `length(masslist)`. To mimic the old function use `na.rm = TRUE`. +#' +#' @note The mz values of the calibrants are first sorted. +#' +#' @param peaklist `matrix` with the identified peaks of a single sample. +#' Required columns are: `"mz"` and `intensity` +#' +#' @param masslist `numeric` with the masses of the calibrants. +#' +#' @param mzabs `numeric(1)` defining the absolute mz deviation. +#' +#' @param mzppm `numeric(1)` defining the mz deviation in ppm. +#' +#' @param neighbours `numeric(1)` with the number of neighbors. +#' +#' @param intensity `character(1)` specifying the column in `peaklist` that +#' contains the peaks' intensity values. +#' +#' @param na.rm `logical(1)` whether results for calibrants for which no peak +#' close enough were found should be excluded from the result `matrix`. +#' @return A `matrix` with 3 columns: +#' + `"pos"`: the position of the peak closest to the corresponding +#' calibrant's mz value. +#' + `"mass"`: the m/z of the peak. +#' + `"dif"`: the difference between the calibrant's and peak's mz. +#' The number of rows matches by default (i.e. with `na.rm = FALSE`) the +#' `length(masslist)`. The `matrix` contains `NA` values for calibrants for +#' which no peak close to the calibrant's mz was found. +#' +#' @md +#' +#' @author Johannes Rainer +#' +#' @noRd +.matchpeaks2 <- function(peaklist, masslist, mzabs = 0.0001, mzppm = 5, + neighbours = 3, intensity = "into", na.rm = FALSE) { + masslist <- sort(masslist) + res_pos <- res_dif <- rep(NA_real_, length(masslist)) + peak_mz <- peaklist[, "mz"] + peak_int <- peaklist[, "into"] + mzppm <- mzppm / 1e6 + peak_mz_maxdiff <- mzabs + (peak_mz * mzppm) + for (i in seq_along(masslist)) { + mzdiffs <- peak_mz - masslist[i] + idx_mzdiffs <- which(abs(mzdiffs) <= peak_mz_maxdiff) + if (length(idx_mzdiffs)) { + the_idx <- idx_mzdiffs + if (length(idx_mzdiffs) > 1) { + ## The neighbours closest. + idx_mzdiffs <- idx_mzdiffs[order(abs(mzdiffs)[idx_mzdiffs])] + idx_mzdiffs <- idx_mzdiffs[1:min(length(idx_mzdiffs), + neighbours)] + ## Select the one with the largest intensity. + the_idx <- idx_mzdiffs[order(peak_int[idx_mzdiffs], + decreasing = TRUE)][1] + } + res_pos[i] <- the_idx + res_dif[i] <- mzdiffs[the_idx] + } + } + not_na <- !is.na(res_pos) + if (!any(not_na)) + stop("Not a single peak close to any of the specified calibrants") + if (na.rm) { + res <- cbind(pos = res_pos[not_na], + mass = peak_mz[res_pos[not_na]], + dif = res_dif[not_na]) + } else { + res <- cbind(pos = res_pos, + mass = peak_mz[res_pos], + dif = res_dif) + } + res +} - if (method!="shift"){ +#' @description Estimates the correction *model*. +#' +#' @param dtable `matrix` as returned by `matchpeaks` or `.matchpeaks2`. +#' +#' @param method `character(1)` defining the method that will be used to +#' perform the calibration. +#' +#' @return A `numeric(2)` with slope and intercept of the linear model. If +#' `method = "shift"` the slope will be `0`. Note that the first element +#' is the slope and the second the intercept! +#' +#' @md +#' +#' @noRd +estimate <- function(dtable, method = c("linear")) { + mdiffs <- dtable[, "dif"] + mposs <- dtable[, "mass"] + + if (method != "shift") { ## complete regression regg <- lm(mdiffs ~ mposs) a <- regg$coefficients[2] b <- regg$coefficients[1] - }else{ + } else { ## only global shift a <- 0 b <- mean(mdiffs) } - if (method != "shift") return (c(a,b)) - else return(c(0,b)) + if (method != "shift") + c(a, b) + else + c(0, b) +} + +#' @description Simple function to calibrate mz values using the provided +#' parameters. +#' +#' @note `mz` values have to be increasingly sorted. At some point we might +#' want to have a more generic implementation that supports, e.g. also +#' loess fits. +#' +#' @param mz `numeric` with the mz values to be calibrated. +#' +#' @param method `character` defining the adjustment method. Can be either +#' `"linear"`, `"shift"` or `"edgeshift"`. +#' +#' @param minMz `numeric(1)` with the minimal mz value. Required for +#' `method = "edgeshift"`. +#' +#' @param maxMz `numeric(1)` with the maximal mz value. Required for +#' `method = "edgeshift"`. +#' +#' @param slope `numeric(1)` with the slope. +#' +#' @param intercept `numeric(1)` with the intercept. +#' +#' @md +#' +#' @author Johannes Rainer +#' +#' @noRd +.calibrate_mz <- function(mz, method = "linear", minMz, maxMz, slope = 0, + intercept) { + if (is.unsorted(mz)) + stop("'mz' values have to be sorted") + if (missing(intercept)) + stop("'intercept' is a required parameter") + method <- match.arg(method, c("shift", "linear", "edgeshift")) + if (method == "edgeshift") { + if (missing(minMz) | missing(maxMz)) + stop("Parameters 'minMz' and 'maxMz' are required for method ", + "'edgeshift'") + shift_lower <- mz < minMz + shift_upper <- mz > maxMz + mz_ <- mz + if (any(shift_lower)) + mz_[shift_lower] <- mz[(max(which(shift_lower)) + 1)] + if (any(shift_upper)) + mz_[shift_upper] <- mz[(min(which(shift_upper)) - 1)] + mz <- mz - (slope * mz_ + intercept) + } else { + mz <- mz - (slope * mz + intercept) + } + mz } diff --git a/R/methods-MsFeatureData.R b/R/methods-MsFeatureData.R index 254eccc2f..2d56dc8e0 100644 --- a/R/methods-MsFeatureData.R +++ b/R/methods-MsFeatureData.R @@ -26,38 +26,35 @@ setMethod("show", "MsFeatureData", function(object) { ## adjustedRtime: getter and setter for the adjustedRtime list. -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setMethod("hasAdjustedRtime", "MsFeatureData", function(object) { - return(!is.null(object$adjustedRtime)) - ## return(any(ls(object) == "adjustedRtime")) + !is.null(object$adjustedRtime) }) -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setMethod("hasFeatures", "MsFeatureData", function(object) { - return(!is.null(object$featureDefinitions)) - ## return(any(ls(object) == "featureDefinitions")) + !is.null(object$featureDefinitions) }) -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setMethod("hasChromPeaks", "MsFeatureData", function(object) { - return(!is.null(object$chromPeaks)) - ## return(any(ls(object) == "chromPeaks")) + !is.null(object$chromPeaks) }) -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setMethod("adjustedRtime", "MsFeatureData", function(object) { if (hasAdjustedRtime(object)) return(object$adjustedRtime) warning("No adjusted retention times available.") return(NULL) }) -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setReplaceMethod("adjustedRtime", "MsFeatureData", function(object, value) { object$adjustedRtime <- value if (validObject(object)) return(object) }) -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setMethod("dropAdjustedRtime", "MsFeatureData", function(object) { if (hasAdjustedRtime(object)) { rm(list = "adjustedRtime", envir = object) @@ -65,40 +62,40 @@ setMethod("dropAdjustedRtime", "MsFeatureData", function(object) { return(object) }) -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setMethod("featureDefinitions", "MsFeatureData", function(object) { if (hasFeatures(object)) return(object$featureDefinitions) warning("No aligned feature information available.") return(NULL) }) -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setReplaceMethod("featureDefinitions", "MsFeatureData", function(object, value) { object$featureDefinitions <- value if (validObject(object)) return(object) }) -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setMethod("dropFeatureDefinitions", "MsFeatureData", function(object) { if (hasFeatures(object)) rm(list = "featureDefinitions", envir = object) return(object) }) -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setMethod("chromPeaks", "MsFeatureData", function(object) { if (hasChromPeaks(object)) return(object$chromPeaks) warning("No chromatographic peaks available.") return(NULL) }) -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setReplaceMethod("chromPeaks", "MsFeatureData", function(object, value) { object$chromPeaks <- value if (validObject(object)) return(object) }) -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setMethod("dropChromPeaks", "MsFeatureData", function(object) { if (hasChromPeaks(object)) rm(list = "chromPeaks", envir = object) diff --git a/R/methods-XCMSnExp.R b/R/methods-XCMSnExp.R index d07e051d0..ae9a3545d 100644 --- a/R/methods-XCMSnExp.R +++ b/R/methods-XCMSnExp.R @@ -158,6 +158,8 @@ setReplaceMethod("adjustedRtime", "XCMSnExp", function(object, value) { #' #' @description \code{featureDefinitions}, \code{featureDefinitions<-}: extract #' or set the correspondence results, i.e. the mz-rt features (peak groups). +#' Similar to the \code{chromPeaks} it is possible to extract features for +#' specified m/z and/or rt ranges (see \code{chromPeaks} for more details). #' #' @return For \code{featureDefinitions}: a \code{DataFrame} with peak grouping #' information, each row corresponding to one mz-rt feature (grouped peaks @@ -171,8 +173,35 @@ setReplaceMethod("adjustedRtime", "XCMSnExp", function(object, value) { #' returns \code{NULL} if no feature definitions are present. #' #' @rdname XCMSnExp-class -setMethod("featureDefinitions", "XCMSnExp", function(object) { - return(featureDefinitions(object@msFeatureData)) +setMethod("featureDefinitions", "XCMSnExp", function(object, mz = numeric(), + rt = numeric(), ppm = 0, + type = "any") { + feat_def <- featureDefinitions(object@msFeatureData) + type <- match.arg(type, c("any", "within")) + ## Select features within rt range. + if (length(rt)) { + rt <- range(rt) + if (type == "within") + keep <- which(feat_def$rtmin >= rt[1] & feat_def$rtmax <= rt[2]) + else + keep <- which(feat_def$rtmax >= rt[1] & feat_def$rtmin <= rt[2]) + feat_def <- feat_def[keep, , drop = FALSE] + } + ## Select peaks within mz range, considering also ppm + if (length(mz) && nrow(feat_def)) { + mz <- range(mz) + ## Increase mz by ppm. + if (is.finite(mz[1])) + mz[1] <- mz[1] - mz[1] * ppm / 1e6 + if (is.finite(mz[2])) + mz[2] <- mz[2] + mz[2] * ppm / 1e6 + if (type == "within") + keep <- which(feat_def$mzmin >= mz[1] & feat_def$mzmax <= mz[2]) + else + keep <- which(feat_def$mzmax >= mz[1] & feat_def$mzmin <= mz[2]) + feat_def <- feat_def[keep, , drop = FALSE] + } + feat_def }) #' @aliases featureDefinitions<- #' @@ -535,10 +564,7 @@ setMethod("dropChromPeaks", "XCMSnExp", function(object) { object <- dropProcessHistories(object, type = .PROCSTEP.RTIME.CORRECTION) object <- dropProcessHistories(object, type = .PROCSTEP.PEAK.GROUPING) object <- dropProcessHistories(object, type = .PROCSTEP.PEAK.FILLING) - ## idx_fd <- which(unlist(lapply(processHistory(object), processType)) == - ## .PROCSTEP.PEAK.DETECTION) - ## if (length(idx_fd) > 0) - ## object@.processHistory <- object@.processHistory[-idx_fd] + object <- dropProcessHistories(object, type = .PROCSTEP.CALIBRATION) newFd <- new("MsFeatureData") newFd@.xData <- .copy_env(object@msFeatureData) newFd <- dropChromPeaks(newFd) @@ -2410,3 +2436,88 @@ setMethod("extractMsData", "XCMSnExp", object <- as(object, "OnDiskMSnExp") extractMsData(object, rt = rt, mz = mz) }) + + +#' @rdname calibrate-calibrant-mass +#' +#' @param object An [XCMSnExp] object. +#' +#' @param param The `CalibrantMassParam` object with the calibration settings. +#' +#' @return The `calibrate` method returns an [XCMSnExp] object with the +#' chromatographic peaks being calibrated. Note that **only** the detected +#' peaks are calibrated, but not the individual mz values in each spectrum. +#' +#' @md +setMethod("calibrate", "XCMSnExp", function(object, param) { + if (missing(param)) { + stop("Argument 'param' is missing") + } else { + if (!is(param, "CalibrantMassParam")) + stop("The calibrate method for 'XCMSnExp' objects requires a ", + "'CalibrantMassParam' object to be passed with argument ", + "'param'") + } + if (isCalibrated(object)) + stop("'object' is already calibrated! Recurrent calibrations are not ", + "supported") + mzs <- .mz(param) + n_samps <- length(fileNames(object)) + if (length(mzs) == 1) + mzs <- replicate(mzs[[1]], n = n_samps, simplify = FALSE) + if (length(mzs) != n_samps) + stop("Number of calibrant mz vectors differs from the number of samples") + startDate <- date() + ## Dropping grouping results. + object <- dropFeatureDefinitions(object) + pks <- chromPeaks(object) + adj_models <- vector("list", length = n_samps) + method <- .method(param) + for (i in 1:n_samps) { + ## This could also be done with indices... + pk_mz <- pks[pks[, "sample"] == i, c("mz", "into")] + order_mz <- order(pk_mz[, 1]) + close_pks <- .matchpeaks2(pk_mz[order_mz, ], mzs[[i]], + mzabs = .mzabs(param), mzppm = .mzppm(param), + neighbours = .neighbors(param)) + if (nrow(close_pks) == 0) { + warning("Sample ", i, ": can not calibrate as no peaks are close to", + "provided mz values") + next + } else { + if (nrow(close_pks) == 1 & method != "shift") { + warning("Sample ", i, ": only a single peak found, falling ", + "back to method = 'shift'") + method <- "shift" + } + } + + prms <- estimate(close_pks, method) + adj_models[[i]] <- prms + a <- prms[1] # slope + b <- prms[2] # intercept + mz_ <- pk_mz[order_mz, 1] + mz_min <- mz_[min(close_pks[, "pos"])] + mz_max <- mz_[max(close_pks[, "pos"])] + pk_mz[order_mz, "mz"] <- .calibrate_mz(mz_, method = method, + minMz = mz_min, maxMz = mz_max, + slope = a, intercept = b) + pks[pks[, "sample"] == i, "mz"] <- pk_mz[, "mz"] + } + + ## Set the new peak definitions. Careful to not drop additional stuff here. + newFd <- new("MsFeatureData") + newFd@.xData <- .copy_env(object@msFeatureData) + chromPeaks(newFd) <- pks + lockEnvironment(newFd, bindings = TRUE) + object@msFeatureData <- newFd + ## Add param to processHistory + xph <- XProcessHistory(param = param, date. = startDate, + type. = .PROCSTEP.CALIBRATION, + fileIndex = 1:n_samps) + object <- addProcessHistory(object, xph) + if (validObject(object)) + object +}) + + diff --git a/R/methods-xcmsSet.R b/R/methods-xcmsSet.R index 284e29b6f..a7b52ad16 100644 --- a/R/methods-xcmsSet.R +++ b/R/methods-xcmsSet.R @@ -241,41 +241,47 @@ setReplaceMethod("profinfo", "xcmsSet", function(object, value) { ############################################################ ## calibrate -setMethod("calibrate", "xcmsSet", function(object,calibrants,method="linear", - mzabs=0.0001, mzppm=5, - neighbours=3, plotres=FALSE) { +setMethod("calibrate", "xcmsSet", function(object, calibrants, + method = "linear", + mzabs = 0.0001, mzppm = 5, + neighbours = 3, plotres = FALSE) { nsamp = length(unique(object@peaks[,"sample"])) - if (!sum(method == c("shift","linear","edgeshift"))) - stop("unknown calibration method!") + match.arg(method, c("shift", "linear", "edgeshift")) if (is.list(calibrants)) if (length(calibrants) != nsamp) stop("Error: Number of masslists differs with number of samples") - for (s in 1:nsamp){ - peaklist = object@peaks[which(object@peaks[,"sample"]==s),] + ## Loop over samples, estimate calibration and apply it. + for (s in 1:nsamp) { + peaklist = object@peaks[which(object@peaks[,"sample"] == s), ] if (is.list(calibrants)) { masslist <- calibrants[s] - }else{ + } else { masslist <- calibrants } + ## Check that peaks are ordered by mz value (issue #200) + if (is.unsorted(peaklist[, "mz"])) + warning("Peaks in sample ", s, " are not sorted by mz value") - masses <- matchpeaks(peaklist,masslist,mzabs,mzppm,neighbours) - if (length(masses)==0){ + masses <- matchpeaks(peaklist, masslist, mzabs, mzppm, neighbours) + if (length(masses) == 0) { warning("No masses close enough!\n") next } - if (nrow(masses)==1 & method!="shift") { - cat("Warning: only one peak found, fallback to shift.") - method="shift" + if (nrow(masses) == 1 & method != "shift") { + warning("Sample ", s, ": only one peak found, falling back to ", + "method = 'shift'") + method = "shift" } - params <- estimate (masses, method) - mzu <- peaklist[,"mz"] - mposs <- masses[,"pos"] - mdiffs <- masses[,"dif"] + ## Estimate the adjustment. + params <- estimate(masses, method) + mzu <- peaklist[, "mz"] + mposs <- masses[, "pos"] + mdiffs <- masses[, "dif"] a <- params[1] b <- params[2] @@ -284,23 +290,32 @@ setMethod("calibrate", "xcmsSet", function(object,calibrants,method="linear", if (method != "edgeshift"){ mzu <- mzu - (a * mzu + b) } else { - mzu[c(1:(min(mposs)-1))] <- mzu[c(1:(min(mposs)-1))] - (a * mzu[min(mposs)] + b) + ## Different adjustment for peaks below the smallest and peaks above + ## the largest mz + mzu[c(1:(min(mposs) - 1))] <- mzu[c(1:(min(mposs) - 1))] - + (a * mzu[min(mposs)] + b) mzu[c((min(mposs)):(max(mposs)))] <- - mzu[c((min(mposs)):(max(mposs)))] - (a * mzu[c((min(mposs)):(max(mposs)))] + b) + mzu[c((min(mposs)):(max(mposs)))] - + (a * mzu[c((min(mposs)):(max(mposs)))] + b) mzu[c((max(mposs)+1):length(mzu))] <- mzu[c((max(mposs)+1):length(mzu))] - (a * mzu[max(mposs)] + b) } peaklist[,"mz"] <- mzu - object@peaks[which(object@peaks[,"sample"]==s),] <- peaklist + object@peaks[which(object@peaks[,"sample"] == s), ] <- peaklist } if (plotres) { plot(mzu[mposs],mdiffs, xlim=c(min(mzu),max(mzu))) - if (method!="edgeshift") {abline(b,a)}else{ - lines(c(min(mzu),mzu[min(mposs)]),c(a * mzu[min(mposs)] + b,a * mzu[min(mposs)] + b)) - lines(c(mzu[min(mposs)],mzu[max(mposs)]),c(a * mzu[min(mposs)] + b,a * mzu[max(mposs)] + b)) - lines(c(mzu[max(mposs)],max(mzu)),c(a * mzu[max(mposs)] + b,a * mzu[max(mposs)] + b)) + if (method!="edgeshift") { + abline(b,a) + } else { + lines(c(min(mzu), mzu[min(mposs)]), + c(a * mzu[min(mposs)] + b,a * mzu[min(mposs)] + b)) + lines(c(mzu[min(mposs)], mzu[max(mposs)]), + c(a * mzu[min(mposs)] + b,a * mzu[max(mposs)] + b)) + lines(c(mzu[max(mposs)], max(mzu)), + c(a * mzu[max(mposs)] + b,a * mzu[max(mposs)] + b)) } } @@ -836,42 +851,72 @@ setMethod("retcor.obiwarp", "xcmsSet", function(object, plottype = c("none", "de idx <- which(seq(1,N) != center) obj1 <- xcmsRaw(object@filepaths[center], profmethod="bin", profstep=0) - ## added t automatically find the correct scan range from the xcmsSet object - if(length(obj1@scantime) != length(object@rt$raw[[center]])){ + ## Scanrange checking: fix for issue #194 + ## Check if we've got the scanrange slot. + scanrange <- NULL + if (.hasSlot(object, "scanrange")) { + if (length(object@scanrange) == 2) + scanrange <- object@scanrange + } else { + if(length(obj1@scantime) != length(object@rt$raw[[center]])){ ## This is in case the xcmsSet was read using a scanrange, i.e. if - ## the data was read in with defining a scan range, then we would have a - ## mismatch here. This code essentially ensures that the retention time - ## of the raw object would match the retention time present in the xcmsSet. - ## This was before the days in which @scanrange was added as a slot to - ## xcmsSet. - ##figure out the scan time range - scantime.start <-object@rt$raw[[center]][1] - scantime.end <-object@rt$raw[[center]][length(object@rt$raw[[center]])] - - scanrange.start <-which.min(abs(obj1@scantime - scantime.start)) - scanrange.end <-which.min(abs(obj1@scantime - scantime.end)) - scanrange<-c(scanrange.start, scanrange.end) - obj1 <- xcmsRaw(object@filepaths[center], profmethod="bin", profstep=0, scanrange=scanrange) - } else{ - scanrange<-NULL - } - + ## the data was read in with defining a scan range, then we would + ## have a mismatch here. This code essentially ensures that the + ## retention time of the raw object would match the retention time + ## present in the xcmsSet. + ## This was before the days in which @scanrange was added as a slot + ## to xcmsSet. + ##figure out the scan time range + scantime.start <- object@rt$raw[[center]][1] + scantime.end <- object@rt$raw[[center]][length(object@rt$raw[[center]])] + scanrange.start <- which.min(abs(obj1@scantime - scantime.start)) + scanrange.end <- which.min(abs(obj1@scantime - scantime.end)) + scanrange <- c(scanrange.start, scanrange.end) + } + } + ## Subset the object if scanrange not NULL + if (!is.null(scanrange)) + obj1 <- obj1[scanrange[1]:scanrange[2]] + + ## ## added t automatically find the correct scan range from the xcmsSet object + ## if(length(obj1@scantime) != length(object@rt$raw[[center]])){ + ## ## This is in case the xcmsSet was read using a scanrange, i.e. if + ## ## the data was read in with defining a scan range, then we would have a + ## ## mismatch here. This code essentially ensures that the retention time + ## ## of the raw object would match the retention time present in the xcmsSet. + ## ## This was before the days in which @scanrange was added as a slot to + ## ## xcmsSet. + ## ##figure out the scan time range + ## scantime.start <-object@rt$raw[[center]][1] + ## scantime.end <-object@rt$raw[[center]][length(object@rt$raw[[center]])] + + ## scanrange.start <-which.min(abs(obj1@scantime - scantime.start)) + ## scanrange.end <-which.min(abs(obj1@scantime - scantime.end)) + ## scanrange<-c(scanrange.start, scanrange.end) + ## obj1 <- xcmsRaw(object@filepaths[center], profmethod="bin", + ## profstep=0, scanrange=scanrange) + ## } else{ + ## scanrange<-NULL + ## } + for (si in 1:length(idx)) { s <- idx[si] cat(samples[s], " ") - + ## ## Might be better to just get the profile matrix from the center object ## outside of the for loop and then modifying a internal variable within ## the loop - avoids creation of two profile matrices in each iteration. - profStepPad(obj1) <- profStep ## (re-)generate profile matrix, since it might have been modified during previous iteration - if(is.null(scanrange)){ - obj2 <- xcmsRaw(object@filepaths[s], profmethod="bin", profstep=0) - } else{ - obj2 <- xcmsRaw(object@filepaths[s], profmethod="bin", profstep=0, scanrange=scanrange) - } + profStepPad(obj1) <- profStep ## (re-)generate profile matrix, since it + ## might have been modified during previous iteration + if(is.null(scanrange)){ + obj2 <- xcmsRaw(object@filepaths[s], profmethod="bin", profstep=0) + } else{ + obj2 <- xcmsRaw(object@filepaths[s], profmethod="bin", profstep=0, + scanrange = scanrange) + } profStepPad(obj2) <- profStep ## generate profile matrix - + mzmin <- min(obj1@mzrange[1], obj2@mzrange[1]) mzmax <- max(obj1@mzrange[2], obj2@mzrange[2]) @@ -931,23 +976,38 @@ setMethod("retcor.obiwarp", "xcmsSet", function(object, plottype = c("none", "de ## Now ensure that the nrow of the profile matrix matches. ## Add empty rows at the beginning if(mzmin < obj1@mzrange[1]) { - seqlen <- length(seq(mzmin, obj1@mzrange[1], profStep))-1 - x <- matrix(0, seqlen,dim(obj1@env$profile)[2]) + ## The profile matrices should not get larger than mz! + max_missing_rows <- mzval - nrow(obj1@env$profile) + low_mz <- seq(mzmin, obj1@mzrange[1], profStep) + ## keep all mz bins that are smaller than mzrange, but ensure that + ## we're not adding more rows than needed. + seqlen <- min(sum(low_mz < obj1@mzrange[1]), max_missing_rows) + ## seqlen <- length(seq(mzmin, obj1@mzrange[1], profStep)) - 1 + x <- matrix(0, seqlen, dim(obj1@env$profile)[2]) obj1@env$profile <- rbind(x, obj1@env$profile) } ## Add emtpy rows at the end. if(mzmax > obj1@mzrange[2]){ - seqlen <- length(seq(obj1@mzrange[2], mzmax, profStep))-1 + max_missing_rows <- mzval - nrow(obj1@env$profile) + high_mz <- seq(obj1@mzrange[2], mzmax, profStep) + seqlen <- min(sum(high_mz > obj1@mzrange[2]), max_missing_rows) + ## seqlen <- length(seq(obj1@mzrange[2], mzmax, profStep)) - 1 x <- matrix(0, seqlen, dim(obj1@env$profile)[2]) obj1@env$profile <- rbind(obj1@env$profile, x) } if(mzmin < obj2@mzrange[1]){ - seqlen <- length(seq(mzmin, obj2@mzrange[1], profStep))-1 + max_missing_rows <- mzval - nrow(obj2@env$profile) + low_mz <- seq(mzmin, obj2@mzrange[1], profStep) + seqlen <- min(sum(low_mz < obj2@mzrange[1]), max_missing_rows) + ## seqlen <- length(seq(mzmin, obj2@mzrange[1], profStep))-1 x <- matrix(0, seqlen, dim(obj2@env$profile)[2]) obj2@env$profile <- rbind(x, obj2@env$profile) } if(mzmax > obj2@mzrange[2]){ - seqlen <- length(seq(obj2@mzrange[2], mzmax, profStep))-1 + max_missing_rows <- mzval - nrow(obj2@env$profile) + high_mz <- seq(obj2@mzrange[2], mzmax, profStep) + seqlen <- min(sum(high_mz > obj2@mzrange[2]), max_missing_rows) + ## seqlen <- length(seq(obj2@mzrange[2], mzmax, profStep)) - 1 x <- matrix(0, seqlen, dim(obj2@env$profile)[2]) obj2@env$profile <- rbind(obj2@env$profile, x) } @@ -956,7 +1016,10 @@ setMethod("retcor.obiwarp", "xcmsSet", function(object, plottype = c("none", "de intensity1 <- obj1@env$profile intensity2 <- obj2@env$profile - if ((mzval * valscantime1 != length(intensity1)) || (mzval * valscantime2 != length(intensity2))) + ## Final check to ensure that our expansion of profile matrix rows was + ## correct. + if ((mzval * valscantime1 != length(intensity1)) || + (mzval * valscantime2 != length(intensity2))) stop("Dimensions of profile matrices do not match !\n") ## Would it be possible to supply non-binned data too??? diff --git a/inst/NEWS b/inst/NEWS index fcedb8c84..cebabc787 100644 --- a/inst/NEWS +++ b/inst/NEWS @@ -1,3 +1,29 @@ +CHANGES IN VERSION 2.99.6 +------------------------- + +NEW FEATURES: +- calibrate,XCMSnExp method that allows to calibrate chromatographic peaks. + +USER VISIBLE CHANGES: +- Export phenoDataFromPaths function (issue $195). +- Add arguments mz and rt to featureDefinitions method allowing to extract + features within the specified ranges. +- Increase n for the density function call in group density-based correspondence + by 2. +- Replace xcmsDirect.Rnw with rmarkdown-based vignette using the new user + interface. + + +BUG FIXES: +- issue #196: removed the unnecessary requirement for same-dimension profile + matrices in adjustRtime,XCMSnExp,ObiwarpParam. +- issue #194: fixes in retcor.obiwarp: 1) subset raw data if scanrange != NULL. + 2) if the mz range of the two files to be aligned differ, expand them + correctly. Depending on the profStep and the mz values/ranges the matrices + were not expanded correctly. +- Potential problems in the plotChromPeakDensity function. + + CHANGES IN VERSION 2.99.5 ------------------------- diff --git a/inst/unitTests/runit.Param-classes.R b/inst/unitTests/runit.Param-classes.R index 6264bd505..7811e25fc 100644 --- a/inst/unitTests/runit.Param-classes.R +++ b/inst/unitTests/runit.Param-classes.R @@ -802,8 +802,6 @@ test_GenericParam <- function() { } test_FillChromPeaksParam <- function() { - library(xcms) - library(RUnit) ## Check getter/setter methods: p <- new("FillChromPeaksParam", expandMz = 0.8) checkEquals(expandMz(p), 0.8) @@ -832,3 +830,26 @@ test_FillChromPeaksParam <- function() { checkException(ppm(p) <- c(2, 2)) checkException(ppm(p) <- -2) } + + +test_CalibrantMassParam <- function() { + + p <- new("CalibrantMassParam") + checkTrue(validObject(p)) + p@method <- "other" + checkException(validObject(p)) + mzs <- rnorm(200, mean = 500) + p <- new("CalibrantMassParam") + p@mz <- list(mzs) + checkException(validObject(p)) + + ## Constructor. + p <- xcms:::CalibrantMassParam(mz = mzs, mzabs = 3, mzppm = 9, + neighbors = 4, method = "shift") + checkEquals(xcms:::.mz(p)[[1]], sort(mzs)) + checkEquals(xcms:::.mzabs(p), 3) + checkEquals(xcms:::.mzppm(p), 9) + checkEquals(xcms:::.neighbors(p), 4L) + checkEquals(xcms:::.method(p), "shift") + +} diff --git a/inst/unitTests/runit.XCMSnExp.R b/inst/unitTests/runit.XCMSnExp.R index 062ad07e0..5c7519f3d 100644 --- a/inst/unitTests/runit.XCMSnExp.R +++ b/inst/unitTests/runit.XCMSnExp.R @@ -193,6 +193,33 @@ test_XCMSnExp_class_accessors <- function() { checkTrue(hasChromPeaks(xod)) checkTrue(hasFeatures(xod)) checkEquals(featureDefinitions(xod), fd) + ## featureDefinitions with mz and/or rt range: + feat_def <- featureDefinitions(xod_xg) + ## Within + mzr <- c(300, 330) + keep_mz <- feat_def$mzmin > mzr[1] & feat_def$mzmax < mzr[2] + checkEquals(featureDefinitions(xod_xg, mz = mzr, type = "within"), + feat_def[keep_mz, ]) + rtr <- c(3000, 3800) + keep_rt <- feat_def$rtmin > rtr[1] & feat_def$rtmax < rtr[2] + checkEquals(featureDefinitions(xod_xg, rt = rtr, type = "within"), + feat_def[keep_rt, ]) + checkEquals(featureDefinitions(xod_xg, rt = rtr, mz = mzr, type = "within"), + feat_def[keep_rt & keep_mz, ]) + ## Any + mzr <- range(featureDefinitions(xod_xg)[2, "mzmed"]) + keep_mz <- feat_def$mzmax >= mzr[1] & feat_def$mzmin <= mzr[2] + checkEquals(featureDefinitions(xod_xg, mz = mzr, type = "any"), + feat_def[keep_mz, , drop = FALSE]) + rtr <- range(3420.006) + keep_rt <- feat_def$rtmax >= rtr[1] & feat_def$rtmin <= rtr[2] + checkTrue(nrow(featureDefinitions(xod_xg, rt = rtr, type = "within")) != + nrow(featureDefinitions(xod_xg, rt = rtr, type = "any"))) + checkEquals(featureDefinitions(xod_xg, rt = rtr, type = "any"), + feat_def[keep_rt, , drop = FALSE]) + checkEquals(featureDefinitions(xod_xg, rt = rtr, mz = mzr, type = "any"), + feat_def[keep_rt & keep_mz, , drop = FALSE]) + ## adjustedRtime checkTrue(!hasAdjustedRtime(xod)) xod2 <- xod diff --git a/inst/unitTests/runit.calibrate.R b/inst/unitTests/runit.calibrate.R new file mode 100644 index 000000000..f9bf019e7 --- /dev/null +++ b/inst/unitTests/runit.calibrate.R @@ -0,0 +1,67 @@ +test_calibrate_XCMSnExp <- function() { + do_plot <- FALSE + + tmp <- filterFile(faahko_xod, file = 1) + + ## Check shift calibration. + mzs <- chromPeaks(tmp)[c(3, 6, 7, 13, 17, 32, 45)] + mzs_shift <- mzs + 0.0001 + prm <- CalibrantMassParam(mz = mzs_shift, method = "shift") + res <- calibrate(tmp, prm) + checkTrue(isCalibrated(res)) + checkEquals(chromPeaks(tmp)[, -1], chromPeaks(res)[, -1]) + checkEquals(chromPeaks(tmp)[, 1] + 0.0001, chromPeaks(res)[, 1]) + diffs <- chromPeaks(res)[, "mz"] - chromPeaks(tmp)[, "mz"] + X <- chromPeaks(res)[, "mz"] + if (do_plot) + plot(X, diffs) + + ## Check linear. + mzs_lin <- mzs + 0.00005 + mzs * 0.000002 + max_dif <- max(mzs_lin - mzs) + prm <- CalibrantMassParam(mz = mzs_lin, method = "linear", mzabs = max_dif) + res <- calibrate(tmp, prm) + checkTrue(isCalibrated(res)) + diffs <- chromPeaks(res)[, "mz"] - chromPeaks(tmp)[, "mz"] + X <- chromPeaks(res)[, "mz"] + if (do_plot) + plot(X, diffs) + res_lm <- lm(diffs ~ X) + checkEquals(unname(coefficients(res_lm)[1]), 0.00005, tolerance = 1e-5) + checkEquals(unname(coefficients(res_lm)[2]), 0.000002, tolerance = 1e-5) + + ## edgeshift + prm <- CalibrantMassParam(mz = mzs_lin, method = "edgeshift", + mzabs = max_dif) + res <- calibrate(tmp, prm) + checkTrue(isCalibrated(res)) + diffs <- chromPeaks(res)[, "mz"] - chromPeaks(tmp)[, "mz"] + X <- chromPeaks(res)[, "mz"] + if (do_plot) + plot(X, diffs) + mz_sorted <- chromPeaks(tmp)[, "mz"] + ## Diff has to be constant before and after the linear range. + lower_idx <- which(chromPeaks(tmp)[, "mz"] < min(mzs)) + checkTrue(all(diffs[lower_idx] == diffs[lower_idx][1])) + upper_idx <- which(chromPeaks(tmp)[, "mz"] > max(mzs)) + checkTrue(all(diffs[upper_idx] == diffs[upper_idx][1])) + lin_idx <- 1:length(diffs) + lin_idx <- lin_idx[!(lin_idx %in% lower_idx)] + lin_idx <- lin_idx[!(lin_idx %in% upper_idx)] + lin_mod <- lm(diffs[lin_idx] ~ X[lin_idx]) + checkEquals(unname(coefficients(lin_mod)[1]), 0.00005, tolerance = 1e-5) + checkEquals(unname(coefficients(lin_mod)[2]), 0.000002, tolerance = 1e-5) + + ## Test with a single mass, fall back to shift. + prm <- CalibrantMassParam(mz = mzs_lin[1], method = "edgeshift", + mzabs = max_dif) + res <- calibrate(tmp, prm) + diffs <- chromPeaks(res)[, "mz"] - chromPeaks(tmp)[, "mz"] + min_diff <- min(abs(chromPeaks(tmp)[, "mz"] - mzs_lin[1])) + checkEquals(diffs, rep(min_diff, length(diffs))) + + ## Check errors. + checkException(calibrate(tmp, 4)) + checkException(calibrate(tmp, CalibrantMassParam(mz = list(mzs, mzs)))) +} + diff --git a/inst/unitTests/runit.matchpeaks.R b/inst/unitTests/runit.matchpeaks.R new file mode 100644 index 000000000..09f6e325f --- /dev/null +++ b/inst/unitTests/runit.matchpeaks.R @@ -0,0 +1,92 @@ +## Check functions in matchpeaks.R +dontrun_matchpeaks <- function() { + library(xcms) + library(RUnit) + library(msdata) + mzdatapath <- system.file("fticr", package = "msdata") + mzdatafiles <- list.files(mzdatapath, recursive = TRUE, full.names = TRUE) + + xs4 <- xcmsSet( + method = "MSW", + files = mzdatafiles[1], + scales = c(1,4, 9), + nearbyPeak = T, + verbose.columns = FALSE, + winSize.noise = 500, + SNR.method = "data.mean", + snthr = 10) + + ## Define the calibrants. + masslist <- xs4@peaks[c(1, 4, 7), "mz"] + xs4@peaks[,"mz"] <- xs4@peaks[,"mz"] + + 0.00001*runif(1,0,0.4)*xs4@peaks[,"mz"] + 0.0001 + + xs4c <- calibrate(xs4, + calibrants=masslist, + method="edgeshift", + mzabs=0.0001, + mzppm=5, + neighbours=3, + plotres=FALSE + ) + ## Do the steps separately + pkl <- peaks(xs4) + mpks <- xcms:::matchpeaks(pkl, masslist) + estm <- xcms:::estimate(mpks) +} + +test_matchpeaks <- function() { + library(xcms) + faahko_file <- system.file('cdf/KO/ko15.CDF', package = "faahKO") + + faahko_xs <- xcmsSet(faahko_file, profparam = list(step = 0), + method = "centWave", noise = 10000, snthresh = 40) + pks <- peaks(faahko_xs) + + calibs <- pks[c(3, 5, 7, 13, 17, 29), "mz"] + + res <- xcms:::matchpeaks(pks, calibs) + res_2 <- xcms:::matchpeaks(pks[order(pks[, "mz"]), ], calibs) +} + +dontrun_implementation_matchpeaks <- function() { + ## Check that xcms:::matchpeaks and xcms:::.matchpeaks2 return the same + ## results. + set.seed(123) + pks <- cbind(mz = sort(abs(rnorm(300, mean = 200, sd = 3))), + into = abs(rnorm(300, mean = 2000, sd = 700))) + masses_idx <- sort(sample(1:nrow(pks), size = 50)) + masses <- pks[masses_idx, "mz"] + res_old <- xcms:::matchpeaks(pks, masses) + res_new <- xcms:::.matchpeaks2(pks, masses) + checkEquals(res_old, res_new) + + res_old <- xcms:::matchpeaks(pks, masses, mzabs = 0, mzppm = 0) + checkEquals(res_old[, "pos"], masses_idx) + res_new <- xcms:::.matchpeaks2(pks, masses, mzabs = 0, mzppm = 0) + checkEquals(res_old, res_new) + + res_old <- xcms:::matchpeaks(pks, masses, mzppm = 0, mzabs = 0.01) + res_new <- xcms:::.matchpeaks2(pks, masses, mzppm = 0, mzabs = 0.01) + checkEquals(res_old, res_new) + + + ## Real data... peaks have to be mz sorted! Report that as issue? + pks <- chromPeaks(faahko_xod) + pks_2 <- pks[pks[, "sample"] == 2, ] + masses_idx <- c(4, 13, 32, 33, 37, 41, 45, 53, 58, 67, 74, 88, 90) + + masses <- pks_2[masses_idx, "mz"] + masses_order <- order(masses) + res_old <- xcms:::matchpeaks(pks_2, masses) + res_new <- xcms:::.matchpeaks2(pks_2, masses) + + ## Why the heck does matchpeaks not work??? + + masses <- masses + 3 * masses / 1e6 + + library(microbenchmark) + microbenchmark(xcms:::matchpeaks(pks, masses), + xcms:::.matchpeaks2(pks, masses)) + ## 10x faster. +} diff --git a/inst/unitTests/runit.xcmsSet.R b/inst/unitTests/runit.xcmsSet.R index 37e2fc1c1..7ef0af193 100644 --- a/inst/unitTests/runit.xcmsSet.R +++ b/inst/unitTests/runit.xcmsSet.R @@ -39,3 +39,11 @@ test.xcmsSetParallel <- function() { checkTrue (nrow((peaks(xset1)@.Data)) == nrow((peaks(xset2)@.Data))) } + +test.phenoDataFromPaths <- function() { + base_dir <- system.file("cdf", package = "faahKO") + cdf_files <- list.files(base_dir, recursive = TRUE, full.names = TRUE) + pd <- phenoDataFromPaths(cdf_files) + checkTrue(colnames(pd) == "class") + checkEquals(levels(pd$class), c("KO", "WT")) +} diff --git a/man/XCMSnExp-class.Rd b/man/XCMSnExp-class.Rd index 6e92b408b..a31d0c54e 100644 --- a/man/XCMSnExp-class.Rd +++ b/man/XCMSnExp-class.Rd @@ -104,7 +104,8 @@ processHistoryTypes() \S4method{adjustedRtime}{XCMSnExp}(object) <- value -\S4method{featureDefinitions}{XCMSnExp}(object) +\S4method{featureDefinitions}{XCMSnExp}(object, mz = numeric(), + rt = numeric(), ppm = 0, type = "any") \S4method{featureDefinitions}{XCMSnExp}(object) <- value @@ -194,12 +195,12 @@ specifying the index of the files/samples for which the \item{bySample}{logical(1) specifying whether results should be grouped by sample.} -\item{rt}{optional \code{numeric(2)} defining the retention time range for -which chromatographic peaks should be returned.} - \item{mz}{optional \code{numeric(2)} defining the mz range for which chromatographic peaks should be returned.} +\item{rt}{optional \code{numeric(2)} defining the retention time range for +which chromatographic peaks should be returned.} + \item{ppm}{optional \code{numeric(1)} specifying the ppm by which the \code{mz} range should be extended. For a value of \code{ppm = 10}, all peaks within \code{mz[1] - ppm / 1e6} and \code{mz[2] + ppm / 1e6} are @@ -369,6 +370,8 @@ process histories. These can be passed with argument \code{type} to the \code{featureDefinitions}, \code{featureDefinitions<-}: extract or set the correspondence results, i.e. the mz-rt features (peak groups). + Similar to the \code{chromPeaks} it is possible to extract features for + specified m/z and/or rt ranges (see \code{chromPeaks} for more details). \code{chromPeaks}, \code{chromPeaks<-}: extract or set the matrix containing the information on identified chromatographic diff --git a/man/calibrate-calibrant-mass.Rd b/man/calibrate-calibrant-mass.Rd new file mode 100644 index 000000000..f4bbea29e --- /dev/null +++ b/man/calibrate-calibrant-mass.Rd @@ -0,0 +1,95 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/DataClasses.R, R/functions-Params.R, +% R/functions-XCMSnExp.R, R/methods-XCMSnExp.R +\docType{class} +\name{CalibrantMassParam-class} +\alias{CalibrantMassParam-class} +\alias{mz,CalibrantMassParam} +\alias{CalibrantMassParam} +\alias{isCalibrated} +\alias{calibrate,XCMSnExp-method} +\title{Calibrant mass based calibration of chromatgraphic peaks} +\usage{ +CalibrantMassParam(mz = list(), mzabs = 1e-04, mzppm = 5, neighbors = 3, + method = "linear") + +isCalibrated(object) + +\S4method{calibrate}{XCMSnExp}(object, param) +} +\arguments{ +\item{mz}{a \code{numeric} or \code{list} of \code{numeric} vectors with reference mz +values. If a \code{numeric} vector is provided, this is used for each sample +in the \code{XCMSnExp} object. If a \code{list} is provided, it's length has to be +equal to the number of samples in the experiment.} + +\item{mzabs}{\code{numeric(1)} the absolute error/deviation for matching peaks to +calibrants (in Da).} + +\item{mzppm}{\code{numeric(1)} the relative error for matching peaks to calibrants +in ppm (parts per million).} + +\item{neighbors}{\code{integer(1)} with the maximal number of peaks within the +permitted distance to the calibrants that are considered. Among these the +mz value of the peak with the largest intensity is used in the +calibration function estimation.} + +\item{method}{\code{character(1)} defining the method that should be used to +estimate the calibration function. Can be \code{"shift"}, \code{"linear"} (default) +or \code{"edgeshift"}.} + +\item{object}{An \link{XCMSnExp} object.} + +\item{param}{The \code{CalibrantMassParam} object with the calibration settings.} +} +\value{ +For \code{CalibrantMassParam}: a \code{CalibrantMassParam} instance. +For \code{calibrate}: an \link{XCMSnExp} object with chromatographic peaks being +calibrated. \strong{Be aware} that the actual raw mz values are not (yet) +calibrated, but \strong{only} the identified chromatographic peaks. + +The \code{CalibrantMassParam} function returns an instance of +the \code{CalibrantMassParam} class with all settings and properties set. + +The \code{calibrate} method returns an \link{XCMSnExp} object with the +chromatographic peaks being calibrated. Note that \strong{only} the detected +peaks are calibrated, but not the individual mz values in each spectrum. +} +\description{ +Calibrate peaks using mz values of known masses/calibrants. +mz values of identified peaks are adjusted based on peaks that are close +to the provided mz values. See details below for more information. + +The \code{isCalibrated} function returns \code{TRUE} if chromatographic +peaks of the \link{XCMSnExp} object \code{x} were calibrated and \code{FALSE} otherwise. +} +\details{ +The method does first identify peaks that are close to the provided +mz values and, given that there difference to the calibrants is smaller +than the user provided cut off (based on arguments \code{mzabs} and \code{mzppm}), +their mz values are replaced with the provided mz values. The mz values +of all other peaks are either globally shifted (for \code{method = "shift"} +or estimated by a linear model through all calibrants. +Peaks are considered close to a calibrant mz if the difference between +the calibrant and its mz is \code{<= mzabs + mz * mzppm /1e6}. + +\strong{Adjustment methods}: adjustment function/factor is estimated using +the difference between calibrant and peak mz values only for peaks +that are close enough to the calibrants. The availabel methods are: +\itemize{ +\item \code{shift}: shifts the m/z of each peak by a global factor which +corresponds to the average difference between peak mz and calibrant mz. +\item \code{linear}: fits a linear model throught the differences between +calibrant and peak mz values and adjusts the mz values of all peaks +using this. +\item \code{edgeshift}: performs same adjustment as \code{linear} for peaks that are +within the mz range of the calibrants and shift outside of it. +} +} +\note{ +\code{CalibrantMassParam} classes don't have exported getter or setter +methods. +} +\author{ +Joachim Bargsten, Johannes Rainer +} diff --git a/man/phenoDataFromPaths.Rd b/man/phenoDataFromPaths.Rd new file mode 100644 index 000000000..edb550196 --- /dev/null +++ b/man/phenoDataFromPaths.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/functions-xcmsSet.R +\name{phenoDataFromPaths} +\alias{phenoDataFromPaths} +\title{Derive experimental design from file paths} +\usage{ +phenoDataFromPaths(paths) +} +\arguments{ +\item{paths}{\code{character} representing the file names (including the full +path) of the experiment's files.} +} +\description{ +The \code{phenoDataFromPaths} function builds a \code{data.frame} +representing the experimental design from the folder structure in which +the files of the experiment are located. +} +\note{ +This function is used by the \emph{old} \code{xcmsSet} function to guess +the experimental design (i.e. group assignment of the files) from the +folders in which the files of the experiment can be found. +} +\examples{ +## List the files available in the faahKO package +base_dir <- system.file("cdf", package = "faahKO") +cdf_files <- list.files(base_dir, recursive = TRUE, full.names = TRUE) +} diff --git a/man/plotChromPeakDensity.Rd b/man/plotChromPeakDensity.Rd index 4909403c2..1bedc0548 100644 --- a/man/plotChromPeakDensity.Rd +++ b/man/plotChromPeakDensity.Rd @@ -4,12 +4,12 @@ \alias{plotChromPeakDensity} \title{Plot chromatographic peak density along the retention time axis} \usage{ -plotChromPeakDensity(object, mz, rt, param = PeakDensityParam(), +plotChromPeakDensity(object, mz, rt, param, simulate = TRUE, col = "#00000080", xlab = "retention time", ylab = "sample", - xlim = range(rt), ...) + xlim = range(rt), main = NULL, ...) } \arguments{ -\item{object}{A \code{\link{XCMSnExp}} object with identified +\item{object}{A \link{XCMSnExp} object with identified chromatographic peaks.} \item{mz}{\code{numeric(2)} defining an mz range for which the peak density @@ -19,8 +19,16 @@ should be plotted.} peak density should be plotted. Defaults to the absolute retention time range of \code{object}.} -\item{param}{\code{\link{PeakDensityParam}} from which parameters for the -\emph{peak density} correspondence algorithm can be extracted.} +\item{param}{\link{PeakDensityParam} from which parameters for the +\emph{peak density} correspondence algorithm can be extracted. If not provided +and if \code{object} contains feature definitions with the correspondence/ +peak grouping being performed by the \emph{peak density} method, the +corresponding parameter class stored in \code{object} is used.} + +\item{simulate}{\code{logical(1)} defining whether correspondence should be +simulated within the specified m/z / rt region or (with +\code{simulate = FALSE}) whether the results from an already performed +correspondence should be shown.} \item{col}{Color to be used for the individual samples. Length has to be 1 or equal to the number of samples in \code{object}.} @@ -32,32 +40,40 @@ or equal to the number of samples in \code{object}.} \item{xlim}{\code{numeric(2)} representing the limits for the x-axis. Defaults to the range of the \code{rt} parameter.} -\item{...}{Additional parameters to be passed to the \code{plot} function.} +\item{main}{\code{character(1)} defining the title of the plot. By default +(for \code{main = NULL}) the mz-range is used.} + +\item{...}{Additional parameters to be passed to the \code{plot} function. Data +point specific parameters such as \code{bg} or \code{pch} have to be of length 1 +or equal to the number of samples.} } \value{ The function is called for its side effect, i.e. to create a plot. } \description{ Plot the density of chromatographic peaks along the retention - time axis and indicate which peaks would be grouped into the same feature - based using the \emph{peak density} correspondence method. Settings for - the \emph{peak density} method can be passed with an - \code{\link{PeakDensityParam}} object to parameter \code{param}. +time axis and indicate which peaks would be (or were) grouped into the +same feature based using the \emph{peak density} correspondence method. +Settings for the \emph{peak density} method can be passed with an +\link{PeakDensityParam} object to parameter \code{param}. If the \code{object} contains +correspondence results and the correspondence was performed with the +\emph{peak groups} method, the results from that correspondence can be +visualized setting \code{simulate = FALSE}. } \details{ The \code{plotChromPeakDensity} function allows to evaluate - different settings for the \emph{peak density} on an mz slice of - interest (e.g. containing chromatographic peaks corresponding to a known - metabolite). - The plot shows the individual peaks that were detected within the - specified \code{mz} slice at their retention time (x-axis) and sample in - which they were detected (y-axis). The density function is plotted as a - black line. Parameters for the \code{density} function are taken from the - \code{param} object. Grey rectangles indicate which chromatographic peaks - would be grouped into a feature by the \emph{peak density} correspondence - method. Parameters for the algorithm are also taken from \code{param}. - See \code{\link{groupChromPeaks-density}} for more information about the - algorithm and its supported settings. +different settings for the \emph{peak density} on an mz slice of +interest (e.g. containing chromatographic peaks corresponding to a known +metabolite). +The plot shows the individual peaks that were detected within the +specified \code{mz} slice at their retention time (x-axis) and sample in +which they were detected (y-axis). The density function is plotted as a +black line. Parameters for the \code{density} function are taken from the +\code{param} object. Grey rectangles indicate which chromatographic peaks +would be grouped into a feature by the \code{peak density} correspondence +method. Parameters for the algorithm are also taken from \code{param}. +See \code{\link[=groupChromPeaks-density]{groupChromPeaks-density()}} for more information about the +algorithm and its supported settings. } \examples{ @@ -94,8 +110,8 @@ plotChromPeakDensity(res, mz = mzr, pch = 16, param = PeakDensityParam(minFraction = 1)) } \seealso{ -\code{\link{groupChromPeaks-density}} for details on the - \emph{peak density} correspondence method and supported settings. +\code{\link[=groupChromPeaks-density]{groupChromPeaks-density()}} for details on the +\emph{peak density} correspondence method and supported settings. } \author{ Johannes Rainer diff --git a/vignettes/new_functionality.org b/vignettes/new_functionality.org index 2898429ea..c5326db28 100644 --- a/vignettes/new_functionality.org +++ b/vignettes/new_functionality.org @@ -1675,4 +1675,36 @@ For each sample: - call the =matchpeaks= function on the peaks matrix and the calibrants (which is supposed to be a numeric vector of mz values. +Global concept: calibration is done on the peaks. Questions: ++ Is there a global calibration value for a file we could store into the + =XCMSnExp= object? If yes we could even apply the calibration to the individual + mz values of a file. Actually, yes, the calibration results could be stored on + a per-file basis in the =XCMSnExp=. Problem is we can not apply one global + calibration to all files. So adding this to the processing queue seems to be a + no-go. + ++ We can add a function to the =processingQueue= that applies different + adjustments depending on the =fileIdx=. Be aware! All subsetting/filtering + approaches do have to update the file index in the =processingQueue=. + +*Idea*: don't need the result class below - should be enough to add the +calibration function (inclusive parameters) to the =processingQueue= of the =MSnExp= object! + +*NOTE*: to enable calibration of =mz= values of a =Spectrum=: ++ Implement a =CalibrationResult= object with slots: + - method + - minMz + - maxMz + - fileIdx + - slope + - intercept ++ Enable adding a =list= of these objects into =MsFeatureData=. ++ Add methods to drop/delete such objects from =MsFeatureData=. ++ =dropChromPeaks= should also drop the =list=. ++ Add function to subset the =list= in the =MsFeatureData=. ++ On subsetting: do also subset the =list=. ++ Implement a =dropCalibration= method that does restore the original mz values. + + + * References diff --git a/vignettes/xcms-direct-injection.Rmd b/vignettes/xcms-direct-injection.Rmd new file mode 100644 index 000000000..575aeb1f8 --- /dev/null +++ b/vignettes/xcms-direct-injection.Rmd @@ -0,0 +1,242 @@ +--- +title: "Grouping FTICR-MS data with xcms" +author: +- name: Joachim Bargsten +- name: Johannes Rainer +package: xcms +output: + BiocStyle::html_document2: + toc_float: true +vignette: > + %\VignetteIndexEntry{Grouping FTICR-MS data with xcms} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteKeywords{Mass Spectrometry, MS, Metabolomics, Bioinformatics} + %\VignetteEncoding{UTF-8} + %\VignetteDepends{xcms,msdata,MassSpecWavelet,BiocStyle} +--- + +# Introduction + +```{r echo = FALSE, results = "hide", message = FALSE} +library(BiocStyle) +``` + +This document describes how to use `r Biocpkg("xcms")` for the analysis of +direct injection mass spec data, including peak detection, calibration and +correspondence (grouping of peaks across samples). + +# Peak detection + +Prior to any other analysis step, peaks have to be identified in the mass spec +data. In contrast to the typical metabolomics workflow, in which peaks are +identified in the chromatographic (time) dimension, in direct injection mass +spec data sets peaks are identified in the m/z dimension. `r Biocpkg("xcms")` +uses functionality from the `MassSpecWavelet` package to identify such peaks. + +Below we load the required packages and set the parallel processing up +(depending on the operating system). + +```{r load-libs, message = FALSE, results = "hide"} +library(xcms) +library(MassSpecWavelet) + +if (.Platform$OS.type == "unix") { + prm <- MulticoreParam(2) +} else { + prm <- SnowParam(2) +} +register(bpstart(prm)) + + +``` + +In this documentation we use an example data set from the `r Biocpkg("msdata")` +package. Assuming that `r Biocpkg("msdata")` is installed, we locate the path of +the package and load the data set. We create also a `data.frame` describing the +experimental setup based on the file names. + +```{r load-data, message = FALSE, results = "hide"} +mzdata_path <- system.file("fticr", package = "msdata") +mzdata_files <- list.files(mzdata_path, recursive = TRUE, full.names = TRUE) + +## Create a data.frame assigning samples to sample groups, i.e. ham4 and ham5. +grp <- rep("ham4", length(mzdata_files)) +grp[grep(basename(mzdata_files), pattern = "^HAM005")] <- "ham5" +pd <- data.frame(filename = basename(mzdata_files), sample_group = grp) + +## Load the data. +ham_raw <- readMSData2(files = mzdata_files, + pdata = new("NAnnotatedDataFrame", pd)) +``` + +The data files are from *direct injection* mass spectrometry experiments, +i.e. we have only a single spectrum available for each sample and no retention +times. + +```{r} +## Only a single spectrum with an *artificial* retention time is available +## for each sample +rtime(ham_raw) +``` + +Peaks are identified within each spectrum using the *mass spec wavelet* method. + +```{r msw} +## Define the parameters for the peak detection +msw <- MSWParam(scales = c(1, 4, 9), nearbyPeak = TRUE, winSize.noise = 500, + SNR.method = "data.mean", snthresh = 10) + +ham_prep <- findChromPeaks(ham_raw, param = msw) + +head(chromPeaks(ham_prep)) +``` + +# Calibration + +The `calibrate` method can be used to correct the m/z values of identified +peaks. The currently implemented method requires identified peaks and a list of +m/z values for known calibrants. The identified peaks m/z values are then +adjusted based on the differences between the calibrants' m/z values and the m/z +values of the closest peaks (within a user defined permitted maximal +distance). Note that this method does presently only calibrate identified peaks, +but not the original m/z values in the spectra. + +Below we demonstrate the `calibrate` method on one of the data files with +artificially defined calibration m/z values. We first subset the data set to the +first data file, extract the m/z values of 3 peaks and modify the values +slightly. + +```{r message = FALSE} +## Subset to the first file. +first_file <- filterFile(ham_prep, file = 1) + +## Extract 3 m/z values +calib_mz <- chromPeaks(first_file)[c(1, 4, 7), "mz"] +calib_mz <- calib_mz + 0.00001 * runif(1, 0, 0.4) * calib_mz + 0.0001 + +``` + +Next we calibrate the data set using the previously defined *artificial* +calibrants. We are using the `"edgeshift"` method for calibration that adjusts +all peaks within the range of the m/z values of the calibrants using a linear +interpolation and shifts all chromatographic peaks outside of that range by a +constant factor (the difference between the lowest respectively largest +calibrant m/z with the closest peak's m/z). Note that in a *real* use case, the +m/z values would obviously represent known m/z of calibrants and would not be +defined on the actual data. + +```{r message = FALSE} +## Set-up the parameter class for the calibration +prm <- CalibrantMassParam(mz = calib_mz, method = "edgeshift", + mzabs = 0.0001, mzppm = 5) +first_file_calibrated <- calibrate(first_file, param = prm) + +``` + +To evaluate the calibration we plot below the difference between the adjusted +and raw m/z values (y-axis) against the raw m/z values. + +```{r calibration-result, fig = TRUE, fig.align = "center"} +diffs <- chromPeaks(first_file_calibrated)[, "mz"] - + chromPeaks(first_file)[, "mz"] + +plot(x = chromPeaks(first_file)[, "mz"], xlab = expression(m/z[raw]), + y = diffs, ylab = expression(m/z[calibrated] - m/z[raw])) + +``` + + +# Correspondence + +Correspondence aims to group peaks across samples to define the *features* (ions +with the same m/z values). Peaks from single spectrum, direct injection MS +experiments can be grouped with the *MZclust* method. Below we perform the +correspondence analysis with the `groupChromPeaks` method using default +settings. + +```{r correspondence, message = FALSE, results = "hide"} +## Using default settings but define sample group assignment +mzc_prm <- MzClustParam(sampleGroups = ham_prep$sample_group) +ham_prep <- groupChromPeaks(ham_prep, param = mzc_prm) + +``` + +Getting an overview of the performed processings: + +```{r} +ham_prep +``` + +The peak group information, i.e. the *feature* definitions can be accessed with +the `featureDefinitions` method. + +```{r} +featureDefinitions(ham_prep) +``` + +Plotting the raw data for direct injection samples involves a little more +processing than for LC/GC-MS data in which we can simply use the `chromatogram` +method to extract the data. Below we extract the m/z-intensity pairs for the +peaks associated with the first feature. We thus first identify the peaks for +that feature and define their m/z values range. Using this range we can +subsequently use the `filterMz` function to sub-set the full data set to the +signal associated with the feature's peaks. On that object we can then call the +`mz` and `intensity` functions to extract the data. + +```{r feature-FT01, fig = TRUE, fig.width = 6, fig.height = 4, fig.align = "center"} +## Get the peaks belonging to the first feature +pks <- chromPeaks(ham_prep)[featureDefinitions(ham_prep)$peakidx[[1]], ] + +## Define the m/z range +mzr <- c(min(pks[, "mzmin"]) - 0.001, max(pks[, "mzmax"]) + 0.001) + +## Subset the object to the m/z range +ham_prep_sub <- filterMz(ham_prep, mz = mzr) + +## Extract the mz and intensity values +mzs <- mz(ham_prep_sub, bySample = TRUE) +ints <- intensity(ham_prep_sub, bySample = TRUE) + +## Plot the data +plot(3, 3, pch = NA, xlim = range(mzs), ylim = range(ints), main = "FT01", + xlab = "m/z", ylab = "intensity") +## Define colors +cols <- rep("#ff000080", length(mzs)) +cols[ham_prep_sub$sample_group == "ham5"] <- "#0000ff80" +tmp <- mapply(mzs, ints, cols, FUN = function(x, y, col) { + points(x, y, col = col, type = "l") +}) + +``` + + +To access the actual intensity values of each feature in each sample the +`featureValue` method can be used. The setting `value = "into"` tells the +function to return the integrated signal for each peak (one representative peak) +per sample. + +```{r} +feat_vals <- featureValues(ham_prep, value = "into") +head(feat_vals) + +``` + +`NA` is reported for features in samples for which no peak was identified at the +feature's m/z value. In some instances there might still be a signal at the +feature's position in the raw data files, but the peak detection failed to +identify a peak. For these cases signal can be recovered using the +`fillChromPeaks` method that integrates all raw signal at the feature's +location. If there is no signal at that location an `NA` is reported. + +```{r fillpeaks, message = FALSE} +ham_prep <- fillChromPeaks(ham_prep, param = FillChromPeaksParam()) + +head(featureValues(ham_prep, value = "into")) +``` + +# Further analysis + +Further analysis, i.e. detection of features/metabolites with significantly +different abundances, or PCA analyses can be performed on the feature matrix +using functionality from other R packages, such as `r Biocpkg("limma")`. + diff --git a/vignettes/xcmsDirect.Rnw b/vignettes/xcmsDirect.Rnw deleted file mode 100644 index c8779eecd..000000000 --- a/vignettes/xcmsDirect.Rnw +++ /dev/null @@ -1,187 +0,0 @@ -% -% NOTE -- ONLY EDIT THE .Rnw FILE!!! The .tex file is -% likely to be overwritten. -% -%\VignetteIndexEntry{Grouping FTICR-MS data with xcms} -%\VignetteKeywords{preprocess, analysis} -%\VignettePackage{xcms} -\documentclass[12pt]{article} - -\usepackage{hyperref} - -\newcommand{\Robject}[1]{{\texttt{#1}}} -\newcommand{\Rfunction}[1]{{\texttt{#1}}} -\newcommand{\Rpackage}[1]{{\textit{#1}}} -\newcommand{\Rclass}[1]{{\textit{#1}}} -\newcommand{\Rmethod}[1]{{\textit{#1}}} -\newcommand{\Rfunarg}[1]{{\textit{#1}}} - -\textwidth=6.2in -\textheight=8.5in -%\parskip=.3cm -\oddsidemargin=.1in -\evensidemargin=.1in -\headheight=-.3in - -\begin{document} -\title{Grouping FTICR-MS data with xcms} -\author{J. Bargsten} -\maketitle - -\section*{Introduction} - -This document describes how to use \Rpackage{xcms} for aligning multiple MS -spectra against each other. - -\section{Prerequisites} -Lots of Preprocessing has to be done before the data is ready for aligning. -First of all \Rpackage{xcms} and \Rpackage{MassSpecWavelet} -are needed for further processing. - -<>= -library(xcms) -library(MassSpecWavelet) - -if (.Platform$OS.type == "unix") { - prm <- MulticoreParam(2) -} else { - prm <- SnowParam(2) -} -register(bpstart(prm)) - -@ - -This documentation uses raw mzdata files from \Rpackage{msdata} as example data -set. Assuming that \Rpackage{msdata} is installed, we locate the path of the -package and extract the datafiles. - -<>= -library(msdata) -mzdatapath <- system.file("fticr", package = "msdata") -mzdatafiles <- list.files(mzdatapath, recursive = TRUE, full.names = TRUE) -cat("Starting xcmsDirect.Rnw") -@ - -The \Rmethod{xcmsSet}-Constructor parses the given files and applies -peakpicking using the MassSpecWavelet algorithm, leading to a \Robject{xcmsSet} -object with 2 sampleclasses, ham4 and ham5, and 5 samples, respectively. - -<>= -data.mean <- "data.mean" -xs <- xcmsSet( - method="MSW", - files=mzdatafiles, - scales=c(1,4,9), - nearbyPeak=T, - verbose.columns = FALSE, - winSize.noise=500, - SNR.method="data.mean", - snthr=10 -) -@ -\section{Calibration} -\Rmethod{calibrate} can be used to correct the m/z values in a \Robject{xcmsSet}. It needs a xcmsSet and a list of m/z value which should be found in the object. To show this on a example a sample of ham4 is created and discalibrated a bit after getting some m/z: - -<>= - -xs4 <- xcmsSet( - method = "MSW", - files = mzdatafiles[1], - scales = c(1,4, 9), - nearbyPeak = T, - verbose.columns = FALSE, - winSize.noise = 500, - SNR.method = "data.mean", - snthr = 10) - -masslist <- xs4@peaks[c(1,4,7),"mz"] -xs4@peaks[,"mz"] <- xs4@peaks[,"mz"] + 0.00001*runif(1,0,0.4)*xs4@peaks[,"mz"] + 0.0001 -@ - -The \Robject{xcmsSet} now can be calibrated again with the m/z from the masslist. The plot shows the reference masses with the distances to the found ones and the regression-line. - -<>= -xs4c <- calibrate(xs4, - calibrants=masslist, - method="edgeshift", - mzabs=0.0001, - mzppm=5, - neighbours=3, - plotres=TRUE - ) -@ - - - -The method "shift" adds a value to each m/z, "linear" does a regression and edgeshift does a regression but uses a shift before the smallest and after the biggest m/z from the calibrants. -\\ -These steps are necessary to create a usable input for \Rmethod{mzClust}. -However, if you have already stored the data in a \Robject{xcmsSet}, you can -skip the steps above. - -\section{Aligning} -Now we can align \Robject{xs} with \Rmethod{mzClust}. The result is a clone of -\Robject{xs} enhanced by the result of \Rmethod{mzClust}. For a description of -the arguments \Rmethod{mzClust} takes, see helppage of the function. - -<>= -xsg <- group(xs, method="mzClust") -xsg -@ - -\Rmethod{mzClust} stores the grouping information like the standard -\Rmethod{group} method of \Rpackage{xcms} suited for retrieval via -\Rmethod{groups} and \Rmethod{groupidx}. An example is shown below. - -<>= -groups(xsg)[1:10,] -peaks(xsg)[groupidx(xsg)[[1]]] -@ - - - -\section{Postprocessing} -In most cases not all samples are in one group. This can be the origin of -serious problems in code, which is based on e.g. -\Rmethod{groupval}. \Rmethod{groupval} sets missing peaks to NA. The solution -is \Rmethod{fillPeaks}. It changes all NA values to random noise based on the raw -data file. -<>= -groupval(xsg)[1,] -xsgf <- fillPeaks(xsg, method="MSW") -groupval(xsgf, "medret", "into")[1:10,] -@ - -The results are suited for instance for heatmaps, etc. - - -\section{Analyzing and Visualizing Results} - -A report showing the most statistically significant differences in -analyte intensities can be generated with the \Rmethod{diffreport} -method. It will automatically sho wthe superimposed peaks in the -spectra for a given number of them, in this case 10. Several of those -chromatograms are shown in Figure~\ref{eic}. - -\begin{figure} -\begin{center} -\begin{tabular}{cc} -\includegraphics[width=0.49\textwidth]{example_spec/001}& -\includegraphics[width=0.49\textwidth]{example_spec/002}\\ -\includegraphics[width=0.49\textwidth]{example_spec/003}& -\includegraphics[width=0.49\textwidth]{example_spec/004}\\ -\end{tabular} -\end{center} -\caption{\label{eic} -Auto-generated extracted spectra for the top three -differentially regulated ions. Darkened lines indicate where the -peaks were integrated for quantitation.} -\end{figure} - -<>= -reporttab <- diffreport(xsgf, "ham4", "ham5", "example", eicmax=4, - h=480, w=640) -reporttab[1:4,] -@ - -\end{document} diff --git a/vignettes/xcmsInstall.Rnw b/vignettes/xcmsInstall.Rnw deleted file mode 100644 index 262408622..000000000 --- a/vignettes/xcmsInstall.Rnw +++ /dev/null @@ -1,203 +0,0 @@ -% -% NOTE -- ONLY EDIT THE .Rnw FILE!!! The .tex file is -% likely to be overwritten. -% -%\VignetteIndexEntry{Installation Instructions for xcms} -%\VignetteDepends{} -%\VignetteKeywords{install} -%\VignettePackage{xcms} -\documentclass[12pt]{article} - -\usepackage{hyperref} - -\newcommand{\Robject}[1]{{\texttt{#1}}} -\newcommand{\Rfunction}[1]{{\texttt{#1}}} -\newcommand{\Rpackage}[1]{{\textit{#1}}} -\newcommand{\Rclass}[1]{{\textit{#1}}} -\newcommand{\Rmethod}[1]{{\textit{#1}}} -\newcommand{\Rfunarg}[1]{{\textit{#1}}} - -\textwidth=6.2in -\textheight=8.5in -%\parskip=.3cm -\oddsidemargin=.1in -\evensidemargin=.1in -\headheight=-.3in - -\begin{document} -\title{Installation Instructions for xcms} -\author{Colin A. Smith} -\maketitle - -\section*{Introduction} - -This document describes how to install \Rpackage{xcms} and, if -necessary, also obtain and install \texttt{R}. The \Rpackage{xcms} -package includes \texttt{C} code which needs to be compiled, and -also uses the NetCDF library for reading AIA format NetCDF mass -spectral data files. Pre-compiled binaries which include the NetCDF -library are available for Windows and Mac OS X. Users of Linux and -other platforms must install the NetCDF library themselves. - -The \Rpackage{xcms} package and a demonstration data package, -\Rpackage{faahKO}, are currently available from several sources. -The first is the web site of the Bioconductor open source software -project. (\url{http://www.bioconductor.org/}) The second is the web -site of the METLIN Metabolite Database. -(\url{http://metlin.scripps.edu/download/}) Both sites contain -source and binary distributions, although due to differences in -distribution, one may host a slightly more up-to-date version than -the other. - -\texttt{R} is available for download through the Comprehensive R -Archive Network (CRAN). Visitors are encouraged to use one of the -many local mirrors of the CRAN site for efficient downloading. -(\url{http://cran.r-project.org/mirrors.html}) While the vignettes -included with \Rpackage{xcms} give many examples of \texttt{R} use -and syntax, new users are strongly encouraged to skim some of the -introductory material in the Manuals section of the \texttt{R} web -site. (\url{http://www.r-project.org/}) ``An Introduction to R'' -is an especially useful starting point. - -\section{Windows Installation} - -To make installation as straightforward as possible for all users, -\Rpackage{xcms} includes a binary version of the NetCDF library in -the \texttt{inst/netcdfdll} subdirectory. The version currently -included is 3.6.1-beta1, as available from the Unidata web -site\footnote{\url{http://www.unidata.ucar.edu/packages/netcdf/}}. - -\begin{enumerate} - -\item Download and install the current version of \texttt{R}. -Detailed instructions for doing so are available on the CRAN site. - -\item Once you have \texttt{R} installed, launch it and select -Biodconductor repository using the \texttt{Packages > Select -repositories...} menu item. - -\item Use the package installer to automatically download and install -\Rpackage{multtest} with the \texttt{Packages > Install package(s)...} -menu item. - -\item Download the \Rpackage{xcms} and \Rpackage{faahKO} Windows -binaries from one of the sources listed in the introduction. - -\item Install \Rpackage{xcms} and \Rpackage{faahKO} using the -\texttt{Packages > Install package(s) from local zip files...} menu -item. - -\end{enumerate} - -\section{Mac OS X Installation} - -The Mac OS X binaries of \Rpackage{xcms} may be installed without -the Developer Tools and without a separate installation of the -NetCDF library. Its code is pre-compiled and statically linked -against the NetCDF library version 3.6.0-p1. If you wish to compile -it yourself, you may obtain the library from software distribution -projects such as Fink\footnote{\url{http://fink.sourceforge.net/}} -or DarwinPorts\footnote{\url{http://netcdf.darwinports.com/}}. -Alternatively, you may compile it yourself using the instructions -provided below. - -\begin{enumerate} - -\item Several of the functions in \Rpackage{xcms} which generate -PNG images require an X11 display device. If it is not already -installed, you will need to install -X11\footnote{\url{http://www.apple.com/downloads/macosx/apple/x11formacosx.html}}. - -\item Download and install the current version of \texttt{R}. -Detailed instructions for doing so are available on the CRAN site. - -\item Download the \Rpackage{xcms} and \Rpackage{faahKO} Mac OS X -binaries from one of the sources listed in the introduction. - -\item Launch \texttt{R} and open the R Package Installer using the -\texttt{Packages \& Data > Package Installer} menu item. Select the -``At User Level'' radio button. - -\item Select ``BioConductor (binaries)'' from the pop up menu and -use the package installer to automatically download and install -\Rpackage{Biobase} and \Rpackage{multtest}. - -If Bioconductor is preparing for its next release and binaries -aren't yet available for your version of \texttt{R}, you will need -to install the Apple Developer -Tools\footnote{\url{http://connect.apple.com/}} to allow installation -of source Bioconductor packages. Use the ``BioConductor (sources)'' -option instead. - -\item Select ``Local Source Package'' from the popup menu and install -the \Rpackage{xcms} and \Rpackage{faahKO} packages you previously -downloaded. - -\end{enumerate} - -\section{Obtaining the NetCDF Library} - -If you are using Linux or another UNIX-like operating system, you -will have to obtain the NetCDF library before installing and using -\Rpackage{xcms}. Many Linux distributions include that package so -in most cases, locating and installing the version that comes with -your distribution will be the best option. However, you may also -install the NetCDF package using the following instructions: - -\begin{enumerate} - -\item Download the gzipped tar file of the NetCDF source -(\texttt{netcdf.tar.gz}) from the Unidata web-site\footnotemark[1]. -Then extract the archive and change to the source directory. - -\begin{verbatim} -tar -xzf netcdf.tar.gz -cd netcdf-*/src -\end{verbatim} - -\item Configure, compile, and install the library. By default it -is installed in the directory you extracted in the previous step. -If you wish to install it in another location, use the \texttt{---prefix} -argument with the configuration script. - -\begin{verbatim} -./configure --prefix=/usr/local -make -make install -\end{verbatim} - -\end{enumerate} - -It is important to note that, when compiled for the x86\_64 -architecture, the NetCDF library must be compiled with the -\texttt{-fPIC} flag to produce position-independent code. Certain -Linux distributions, such as SuSE Professional 9.2, do not yet -enable that option when packaging the NetCDF library. In that case -you must compile and install the library yourself using the -instructions above. To enable that flag, set the \texttt{CFLAGS} -environment variable prior to compilation. - -\begin{verbatim} -export CFLAGS=-fPIC (for sh, bash, etc.) -setenv CFLAGS -fPIC (for csh, tcsh, etc.) -\end{verbatim} - -\section{Obtaining the \Rpackage{rgl} Package} - -Though not listed in any of the dependencies of \Rpackage{xcms}, -the \Rpackage{rgl} package does get limited use. It provides an -interface for creating interactive, 3D graphics using OpenGL. The -\Rpackage{rgl} package is currently under development and does not -yet provide sufficient functionality or stability to warrant its -listing as an official dependency. It is used by a single -method, \Rmethod{plotSurf}, for plotting out a 3D surface representation -of part of an LC/MS or GC/MS experiment. Due to limitations in -\Rpackage{rgl}, axis labels are currently not implemented. However, -it can be instructive for visualizing a small number of peaks in -three dimensions. - -The best place to obtain source and Windows binary packages of -\Rpackage{rgl} is directly from CRAN. Mac OS X binaries are available -in the same place you download the \texttt{R} installer. - -\end{document}