diff --git a/DESCRIPTION b/DESCRIPTION index b628768..643caac 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: metaboMisc Title: Miscellaneous Functions for Metabolomics Analyses -Version: 0.5.7 +Version: 0.5.8 Authors@R: person("Jasen", "Finch", email = "jsf9@aber.ac.uk", role = c("aut", "cre")) Description: Miscellaneous helper functions for metabolomics analyses that do not yet have a permanent home. URL: https://jasenfinch.github.io/metaboMisc diff --git a/NAMESPACE b/NAMESPACE index 637c14e..0804971 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -83,6 +83,7 @@ importFrom(profilePro,processingParameters) importFrom(profilePro,technique) importFrom(purrr,map) importFrom(purrr,map_chr) +importFrom(purrr,map_df) importFrom(readr,write_csv) importFrom(stats,IQR) importFrom(stats,quantile) diff --git a/NEWS.md b/NEWS.md index a4098f8..afb4bb1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# metabMisc 0.5.8 + +* Numbers of characters in strings are now limited by `sanitiseTable()`. + # metaboMisc 0.5.7 * Removed `aberHRML/metaboData` from the Remotes field in the DESCRIPTION to ensure that the CRAN version of metaboData is installed. diff --git a/R/sanitise.R b/R/sanitise.R index 1351a1d..dda734f 100644 --- a/R/sanitise.R +++ b/R/sanitise.R @@ -1,15 +1,17 @@ #' Sanitise a data table -#' @description Sanitise a data table by restricting the number of rows and rounding numeric columns. +#' @description Sanitise a data table by restricting the number of rows or characters and rounding numeric columns. #' @param x A tibble or data.frame containing the data to be sanitised #' @param maxRows Maximum number of rows with which to restrict the table #' @param sigFig Significant figures with which to round numeric columns +#' @param maxCharacters Maximum number of characters allowed in a string before it is truncated #' @examples #' sanitiseTable(iris,maxRows = 10,sigFig = 1) #' @importFrom dplyr mutate_if +#' @importFrom purrr map_df #' @export -sanitiseTable <- function(x,maxRows = 5000,sigFig = 3){ +sanitiseTable <- function(x,maxRows = 5000,sigFig = 3,maxCharacters = 100){ x <- mutate_if(x,is.numeric,signif,digits = sigFig) if (nrow(x) > maxRows){ @@ -17,5 +19,18 @@ sanitiseTable <- function(x,maxRows = 5000,sigFig = 3){ x <- x[seq_len(maxRows),] } + a <- map_df(x,~{ + if (typeof(.x) == 'character'){ + limit_characters <- .x %>% + nchar() %>% + {. > maxCharacters} + + .x[limit_characters] <- str_sub(.x[limit_characters],1,maxCharacters) %>% + str_c(.,'...') + } + + return(.x) + }) + return(x) } diff --git a/_pkgdown.yml b/_pkgdown.yml index 146a9c3..3ed8d62 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1 +1 @@ -url: https://jasenfinch.github.io/metaboMisc/ \ No newline at end of file +url: https://jasenfinch.github.io/metaboMisc/ diff --git a/docs/404.html b/docs/404.html index e24e55f..688cbb6 100644 --- a/docs/404.html +++ b/docs/404.html @@ -71,7 +71,7 @@ metaboMisc - 0.5.7 + 0.5.8 diff --git a/docs/authors.html b/docs/authors.html index d46507d..e766a83 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -71,7 +71,7 @@ metaboMisc - 0.5.7 + 0.5.8 diff --git a/docs/index.html b/docs/index.html index f85b484..24b1da3 100644 --- a/docs/index.html +++ b/docs/index.html @@ -31,7 +31,7 @@ metaboMisc - 0.5.7 + 0.5.8 diff --git a/docs/news/index.html b/docs/news/index.html index 235ee42..ac75df0 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -71,7 +71,7 @@ metaboMisc - 0.5.7 + 0.5.8 @@ -114,6 +114,13 @@

Changelog

Source: NEWS.md +
+

+metabMisc 0.5.8

+ +

metaboMisc 0.5.7

@@ -176,7 +183,7 @@

  • Improved documentation and added examples.

  • Added unit testing infrastructure.

  • Added detectPretreatmentParameters and detectModellingParameters methods.

  • -
  • The magrittr pipe (%>%) is now re-exported.

  • +
  • The magrittr pipe (%>%) is now re-exported.

  • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 6e16535..696fe44 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 2.11.4 pkgdown: 1.6.1 pkgdown_sha: ~ articles: {} -last_built: 2021-09-27T10:19Z +last_built: 2021-11-17T09:52Z urls: reference: https://jasenfinch.github.io/metaboMisc//reference article: https://jasenfinch.github.io/metaboMisc//articles diff --git a/docs/reference/Rplot002.png b/docs/reference/Rplot002.png index 70b7b59..a0035e2 100644 Binary files a/docs/reference/Rplot002.png and b/docs/reference/Rplot002.png differ diff --git a/docs/reference/addAssignments.html b/docs/reference/addAssignments.html index 2898bbb..72ba628 100644 --- a/docs/reference/addAssignments.html +++ b/docs/reference/addAssignments.html @@ -72,7 +72,7 @@ metaboMisc - 0.5.7 + 0.5.8
    diff --git a/docs/reference/convertSampleInfo.html b/docs/reference/convertSampleInfo.html index 344f27f..b6fb723 100644 --- a/docs/reference/convertSampleInfo.html +++ b/docs/reference/convertSampleInfo.html @@ -72,7 +72,7 @@ metaboMisc - 0.5.7 + 0.5.8 diff --git a/docs/reference/detectBatchDiff.html b/docs/reference/detectBatchDiff.html index d892d75..548b349 100644 --- a/docs/reference/detectBatchDiff.html +++ b/docs/reference/detectBatchDiff.html @@ -72,7 +72,7 @@ metaboMisc - 0.5.7 + 0.5.8 @@ -153,25 +153,44 @@

    Details

    Analysis of Variance (ANOVA) is used to detect differences in total ion count (TIC) averages between batches/blocks.

    Examples

    -
    ## Retrieve file paths and sample information for example data -files <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes')[1:2] - -info <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes')[1:2,] - -## Perform spectral binning -analysis <- binneR::binneRlyse(files, - info, - parameters = binneR::detectParameters(files)) -
    #> -#> Attaching package: ‘purrr’
    #> The following object is masked from ‘package:metaboMisc’: -#> -#> reduce
    #> binneR v2.5.3 Mon Sep 27 11:19:18 2021
    #> ________________________________________________________________________________
    #> Scans: 5:14
    #> ________________________________________________________________________________
    #> Reading raw data
    #> Gathering bins
    #> Removing single scan events
    #> Averaging intensities across scans
    #> Calculating bin metrics
    #> Calculating accurate m/z
    #> Building intensity matrix
    #> Gathering file headers
    #>
    #> Completed! [2.9S]
    -## Detect batch differences -batch_diff <- detectBatchDiff(analysis) -
    #> Batches with < 3 replicates removed: "3", "5"
    #> Only 1 batch detected, skipping detection
    -## Display batch diffferences -batch_diff -
    #> NULL
    +
    ## Retrieve file paths and sample information for example data
    +files <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes')[1:2]
    +
    +info <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes')[1:2,]
    +
    +## Perform spectral binning
    +analysis <- binneR::binneRlyse(files, 
    +                               info, 
    +                               parameters = binneR::detectParameters(files))
    +#> 
    +#> Attaching package: ‘purrr’
    +#> The following object is masked from ‘package:metaboMisc’:
    +#> 
    +#>     reduce
    +#> binneR v2.6.2 Wed Nov 17 09:52:25 2021
    +#> ________________________________________________________________________________
    +#> Scans: 5:14 
    +#> ________________________________________________________________________________
    +#> Reading raw data
    +#> Gathering bins
    +#> Removing single scan events
    +#> Averaging intensities across scans
    +#> Calculating bin metrics
    +#> Calculating accurate m/z
    +#> Building intensity matrix
    +#> Gathering file headers
    +#> 
    +#> Completed! [2.6S]
    +
    +## Detect batch differences
    +batch_diff <- detectBatchDiff(analysis)
    +#> Batches with < 3 replicates removed: "3", "5"
    +#> Only 1 batch detected, skipping detection
    +
    +## Display batch diffferences
    +batch_diff
    +#> NULL
    +
    @@ -149,22 +149,37 @@

    Details

    Samples with a total ion count (TIC) below 1.5 times the inter-quartile range are detected as miss injections.

    Examples

    -
    ## Retrieve file paths and sample information for example data -files <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes')[1:2] - -info <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes')[1:2,] - -## Perform spectral binning -analysis <- binneR::binneRlyse(files, - info, - parameters = binneR::detectParameters(files)) -
    #> binneR v2.5.3 Mon Sep 27 11:19:22 2021
    #> ________________________________________________________________________________
    #> Scans: 5:14
    #> ________________________________________________________________________________
    #> Reading raw data
    #> Gathering bins
    #> Removing single scan events
    #> Averaging intensities across scans
    #> Calculating bin metrics
    #> Calculating accurate m/z
    #> Building intensity matrix
    #> Gathering file headers
    #>
    #> Completed! [2.3S]
    -## Detect miss injections -miss_injections <- detectMissInjections(analysis) - -## Display detected miss injections -miss_injections$missInjections -
    #> numeric(0)
    +
    ## Retrieve file paths and sample information for example data
    +files <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes')[1:2]
    +
    +info <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes')[1:2,]
    +
    +## Perform spectral binning
    +analysis <- binneR::binneRlyse(files, 
    +                               info, 
    +                               parameters = binneR::detectParameters(files))
    +#> binneR v2.6.2 Wed Nov 17 09:52:29 2021
    +#> ________________________________________________________________________________
    +#> Scans: 5:14 
    +#> ________________________________________________________________________________
    +#> Reading raw data
    +#> Gathering bins
    +#> Removing single scan events
    +#> Averaging intensities across scans
    +#> Calculating bin metrics
    +#> Calculating accurate m/z
    +#> Building intensity matrix
    +#> Gathering file headers
    +#> 
    +#> Completed! [1.9S]
    +
    +## Detect miss injections
    +miss_injections <- detectMissInjections(analysis)
    +
    +## Display detected miss injections
    +miss_injections$missInjections
    +#> numeric(0)
    +
    @@ -157,22 +157,37 @@

    Value

    S4 object of class AnalysisParameters

    Examples

    -
    ## Retrieve file paths and sample information for example data -files <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes')[1:2] - -info <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes')[1:2,] - -## Perform spectral binning -analysis <- binneR::binneRlyse(files, - info, - parameters = binneR::detectParameters(files)) -
    #> binneR v2.5.3 Mon Sep 27 11:19:25 2021
    #> ________________________________________________________________________________
    #> Scans: 5:14
    #> ________________________________________________________________________________
    #> Reading raw data
    #> Gathering bins
    #> Removing single scan events
    #> Averaging intensities across scans
    #> Calculating bin metrics
    #> Calculating accurate m/z
    #> Building intensity matrix
    #> Gathering file headers
    #>
    #> Completed! [2.2S]
    -## Detect modelling parameters -modelling_parameters <- detectModellingParameters(analysis) - -modelling_parameters -
    #> Parameters: -#>
    +
    ## Retrieve file paths and sample information for example data
    +files <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes')[1:2]
    +
    +info <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes')[1:2,]
    +
    +## Perform spectral binning
    +analysis <- binneR::binneRlyse(files, 
    +                               info, 
    +                               parameters = binneR::detectParameters(files))
    +#> binneR v2.6.2 Wed Nov 17 09:52:32 2021
    +#> ________________________________________________________________________________
    +#> Scans: 5:14 
    +#> ________________________________________________________________________________
    +#> Reading raw data
    +#> Gathering bins
    +#> Removing single scan events
    +#> Averaging intensities across scans
    +#> Calculating bin metrics
    +#> Calculating accurate m/z
    +#> Building intensity matrix
    +#> Gathering file headers
    +#> 
    +#> Completed! [1.9S]
    +
    +## Detect modelling parameters
    +modelling_parameters <- detectModellingParameters(analysis)
    +
    +modelling_parameters
    +#> Parameters:
    +#> 
    +
    @@ -142,55 +142,71 @@

    Value

    S4 object of class AnalysisParameters

    Examples

    -
    ## Retreive example file paths and sample information -file_paths <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes') %>% - .[61:63] - -sample_information <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes') %>% - dplyr::filter(name == 'QC01' | name == 'QC02' | name == 'QC03') - -## Detect spectral binning parameters -bp <- binneR::detectParameters(file_paths) - -## Perform spectral binning -bd <- binneR::binneRlyse(file_paths,sample_information,bp) -
    #> binneR v2.5.3 Mon Sep 27 11:19:28 2021
    #> ________________________________________________________________________________
    #> Scans: 5:13
    #> ________________________________________________________________________________
    #> Reading raw data
    #> Gathering bins
    #> Removing single scan events
    #> Averaging intensities across scans
    #> Calculating bin metrics
    #> Calculating accurate m/z
    #> Building intensity matrix
    #> Gathering file headers
    #>
    #> Completed! [3.2S]
    -## Detect pre-treatment parameters -pp <- detectPretreatmentParameters(bd) -
    #> Only 1 batch detected, skipping detection
    -pp -
    #> Parameters: -#> pre-treatment -#> QC -#> occupancyFilter -#> cls = class -#> QCidx = QC -#> occupancy = 2/3 -#> impute -#> cls = class -#> QCidx = QC -#> occupancy = 2/3 -#> parallel = variables -#> seed = 1234 -#> RSDfilter -#> cls = class -#> QCidx = QC -#> RSDthresh = 50 -#> removeQC -#> cls = class -#> QCidx = QC -#> occupancyFilter -#> maximum -#> cls = class -#> occupancy = 2/3 -#> impute -#> class -#> cls = class -#> occupancy = 2/3 -#> seed = 1234 -#> transform -#> TICnorm -#>
    +
    ## Retreive example file paths and sample information 
    +file_paths <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes') %>% 
    +   .[61:63]
    +
    +sample_information <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes') %>% 
    +    dplyr::filter(name == 'QC01' | name == 'QC02' | name == 'QC03')
    +
    +## Detect spectral binning parameters
    +bp <- binneR::detectParameters(file_paths)
    +
    +## Perform spectral binning
    +bd <- binneR::binneRlyse(file_paths,sample_information,bp)
    +#> binneR v2.6.2 Wed Nov 17 09:52:35 2021
    +#> ________________________________________________________________________________
    +#> Scans: 5:13 
    +#> ________________________________________________________________________________
    +#> Reading raw data
    +#> Gathering bins
    +#> Removing single scan events
    +#> Averaging intensities across scans
    +#> Calculating bin metrics
    +#> Calculating accurate m/z
    +#> Building intensity matrix
    +#> Gathering file headers
    +#> 
    +#> Completed! [2.7S]
    +
    +## Detect pre-treatment parameters
    +pp <- detectPretreatmentParameters(bd) 
    +#> Only 1 batch detected, skipping detection
    +
    +pp
    +#> Parameters:
    +#> pre-treatment
    +#> 	QC
    +#> 		occupancyFilter
    +#> 			cls = class
    +#> 			QCidx = QC
    +#> 			occupancy = 2/3
    +#> 		impute
    +#> 			cls = class
    +#> 			QCidx = QC
    +#> 			occupancy = 2/3
    +#> 			parallel = variables
    +#> 			seed = 1234
    +#> 		RSDfilter
    +#> 			cls = class
    +#> 			QCidx = QC
    +#> 			RSDthresh = 50
    +#> 		removeQC
    +#> 			cls = class
    +#> 			QCidx = QC
    +#> 	occupancyFilter
    +#> 		maximum
    +#> 			cls = class
    +#> 			occupancy = 2/3
    +#> 	impute
    +#> 		class
    +#> 			cls = class
    +#> 			occupancy = 2/3
    +#> 			seed = 1234
    +#> 	transform
    +#> 		TICnorm
    +#> 
    +
    diff --git a/docs/reference/exportCSV.html b/docs/reference/exportCSV.html index a381af3..118d4f3 100644 --- a/docs/reference/exportCSV.html +++ b/docs/reference/exportCSV.html @@ -72,7 +72,7 @@ metaboMisc - 0.5.7 + 0.5.8 @@ -147,8 +147,9 @@

    Details

    If the file path directory does not exist, the directory is created prior to export.

    Examples

    -
    exportCSV(iris, "iris.csv") -
    #> [1] "iris.csv"
    +
    exportCSV(iris, "iris.csv")
    +#> [1] "iris.csv"
    +
    @@ -139,22 +139,37 @@

    Value

    A tibble containing feature summaries

    Examples

    -
    ## Retrieve file paths and sample information for example data -files <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes')[1:2] - -info <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes')[1:2,] - -## Perform spectral binning -analysis <- binneR::binneRlyse(files, - info, - parameters = binneR::detectParameters(files)) -
    #> binneR v2.5.3 Mon Sep 27 11:19:33 2021
    #> ________________________________________________________________________________
    #> Scans: 5:14
    #> ________________________________________________________________________________
    #> Reading raw data
    #> Gathering bins
    #> Removing single scan events
    #> Averaging intensities across scans
    #> Calculating bin metrics
    #> Calculating accurate m/z
    #> Building intensity matrix
    #> Gathering file headers
    #>
    #> Completed! [2.3S]
    -featureSummary(analysis) -
    #> # A tibble: 2 × 3 -#> Mode `Number of bins` `Missing Data (%)` -#> <chr> <int> <dbl> -#> 1 Negative 1188 6.48 -#> 2 Positive 1550 9.68
    +
    ## Retrieve file paths and sample information for example data
    +files <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes')[1:2]
    +
    +info <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes')[1:2,]
    +
    +## Perform spectral binning
    +analysis <- binneR::binneRlyse(files, 
    +                               info, 
    +                               parameters = binneR::detectParameters(files))
    +#> binneR v2.6.2 Wed Nov 17 09:52:39 2021
    +#> ________________________________________________________________________________
    +#> Scans: 5:14 
    +#> ________________________________________________________________________________
    +#> Reading raw data
    +#> Gathering bins
    +#> Removing single scan events
    +#> Averaging intensities across scans
    +#> Calculating bin metrics
    +#> Calculating accurate m/z
    +#> Building intensity matrix
    +#> Gathering file headers
    +#> 
    +#> Completed! [3.5S]
    +
    +featureSummary(analysis)
    +#> # A tibble: 2 × 3
    +#>   Mode     `Number of bins` `Missing Data (%)`
    +#>   <chr>               <int>              <dbl>
    +#> 1 Negative             1188               6.48
    +#> 2 Positive             1550               9.68
    +
    diff --git a/docs/reference/plotRSD-1.png b/docs/reference/plotRSD-1.png index 2fb9f21..ef02af5 100644 Binary files a/docs/reference/plotRSD-1.png and b/docs/reference/plotRSD-1.png differ diff --git a/docs/reference/plotRSD-2.png b/docs/reference/plotRSD-2.png index 1ec08ff..a0fbb88 100644 Binary files a/docs/reference/plotRSD-2.png and b/docs/reference/plotRSD-2.png differ diff --git a/docs/reference/plotRSD.html b/docs/reference/plotRSD.html index febf8b5..31e0627 100644 --- a/docs/reference/plotRSD.html +++ b/docs/reference/plotRSD.html @@ -72,7 +72,7 @@ metaboMisc - 0.5.7 + 0.5.8 @@ -144,20 +144,39 @@

    Value

    A list of plots of RSD distributions

    Examples

    -
    ## Retrieve file paths and sample information for example data -files <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes')[1:2] - -info <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes')[1:2,] - -## Perform spectral binning -analysis <- binneR::binneRlyse(files, - info, - parameters = binneR::detectParameters(files)) -
    #> binneR v2.5.3 Mon Sep 27 11:19:36 2021
    #> ________________________________________________________________________________
    #> Scans: 5:14
    #> ________________________________________________________________________________
    #> Reading raw data
    #> Gathering bins
    #> Removing single scan events
    #> Averaging intensities across scans
    #> Calculating bin metrics
    #> Calculating accurate m/z
    #> Building intensity matrix
    #> Gathering file headers
    #>
    #> Completed! [3S]
    -## Plot RSD distributions -plotRSD(analysis) -
    #> $n
    #> -#> $p
    #>
    +
    ## Retrieve file paths and sample information for example data
    +files <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes')[1:2]
    +
    +info <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes')[1:2,]
    +
    +## Perform spectral binning
    +analysis <- binneR::binneRlyse(files, 
    +                               info, 
    +                               parameters = binneR::detectParameters(files))
    +#> binneR v2.6.2 Wed Nov 17 09:52:44 2021
    +#> ________________________________________________________________________________
    +#> Scans: 5:14 
    +#> ________________________________________________________________________________
    +#> Reading raw data
    +#> Gathering bins
    +#> Removing single scan events
    +#> Averaging intensities across scans
    +#> Calculating bin metrics
    +#> Calculating accurate m/z
    +#> Building intensity matrix
    +#> Gathering file headers
    +#> 
    +#> Completed! [3S]
    +
    +## Plot RSD distributions
    +plotRSD(analysis)
    +#> $n
    +
    +#> 
    +#> $p
    +
    +#> 
    +
    @@ -150,66 +150,84 @@

    Value

    S4 object of class Analysis

    Examples

    -
    library(metabolyseR) -
    #> -#> Attaching package: ‘metabolyseR’
    #> The following object is masked from ‘package:stats’: -#> -#> anova
    #> The following objects are masked from ‘package:base’: -#> -#> raw, split
    -## Retrieve file paths and sample information for example data -files <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes')[1:2] - -info <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes')[1:2,] - -## Detect spectral binning parameters -bp <- binneR::detectParameters(files) - -## Perform spectral binning -analysis <- binneR::binneRlyse(files, - info, - parameters = bp) -
    #> binneR v2.5.3 Mon Sep 27 11:19:42 2021
    #> ________________________________________________________________________________
    #> Scans: 5:14
    #> ________________________________________________________________________________
    #> Reading raw data
    #> Gathering bins
    #> Removing single scan events
    #> Averaging intensities across scans
    #> Calculating bin metrics
    #> Calculating accurate m/z
    #> Building intensity matrix
    #> Gathering file headers
    #>
    #> Completed! [2.3S]
    -## Declare pre-treatment parameters -pre_treatment_parameters <- analysisParameters('pre-treatment') -parameters(pre_treatment_parameters, - 'pre-treatment') <- preTreatmentParameters( - list( - occupancyFilter = 'maximum', - impute = 'all', - transform = 'TICnorm' - ) -) -changeParameter(pre_treatment_parameters,'parallel') <- 'no' - -## Perform pre-treatment -pre_treated_data <- preTreatModes(analysis, - pre_treatment_parameters) -
    #> -#> metabolyseR v0.14.3 Mon Sep 27 11:19:44 2021 -#> ________________________________________________________________________________ -#> Parameters: -#> pre-treatment -#> occupancyFilter -#> maximum -#> cls = class -#> occupancy = 2/3 -#> impute -#> all -#> occupancy = 2/3 -#> parallel = no -#> seed = 1234 -#> transform -#> TICnorm -#> -#> ________________________________________________________________________________ -#> -#> Negative modeNegative mode [0.5S] -#> Positive modePositive mode [0.6S] -#> ________________________________________________________________________________ -#> -#> Complete! [1.2S] -#>
    +
    library(metabolyseR)
    +#> 
    +#> Attaching package: ‘metabolyseR’
    +#> The following object is masked from ‘package:stats’:
    +#> 
    +#>     anova
    +#> The following objects are masked from ‘package:base’:
    +#> 
    +#>     raw, split
    +
    +## Retrieve file paths and sample information for example data
    +files <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes')[1:2]
    +
    +info <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes')[1:2,]
    +
    +## Detect spectral binning parameters
    +bp <- binneR::detectParameters(files)
    +
    +## Perform spectral binning
    +analysis <- binneR::binneRlyse(files, 
    +                               info, 
    +                               parameters = bp)
    +#> binneR v2.6.2 Wed Nov 17 09:52:51 2021
    +#> ________________________________________________________________________________
    +#> Scans: 5:14 
    +#> ________________________________________________________________________________
    +#> Reading raw data
    +#> Gathering bins
    +#> Removing single scan events
    +#> Averaging intensities across scans
    +#> Calculating bin metrics
    +#> Calculating accurate m/z
    +#> Building intensity matrix
    +#> Gathering file headers
    +#> 
    +#> Completed! [2.5S]
    +
    +## Declare pre-treatment parameters
    +pre_treatment_parameters <- analysisParameters('pre-treatment')
    +parameters(pre_treatment_parameters,
    +                        'pre-treatment') <- preTreatmentParameters(
    + list(
    +   occupancyFilter = 'maximum',
    +   impute = 'all',
    +   transform = 'TICnorm'
    + )
    +)
    +changeParameter(pre_treatment_parameters,'parallel') <- 'no'
    +
    +## Perform pre-treatment
    +pre_treated_data <- preTreatModes(analysis,
    +                                  pre_treatment_parameters)
    +#> 
    +#> metabolyseR v0.14.5 Wed Nov 17 09:52:53 2021
    +#> ________________________________________________________________________________
    +#> Parameters:
    +#> pre-treatment
    +#> 	occupancyFilter
    +#> 		maximum
    +#> 			cls = class
    +#> 			occupancy = 2/3
    +#> 	impute
    +#> 		all
    +#> 			occupancy = 2/3
    +#> 			parallel = no
    +#> 			seed = 1234
    +#> 	transform
    +#> 		TICnorm
    +#> 
    +#> ________________________________________________________________________________
    +#> 
    +#> Negative modeNegative mode 		 [1.1S]
    +#> Positive modePositive mode 		 [0.9S]
    +#> ________________________________________________________________________________
    +#> 
    +#> Complete! [2.1S]
    +#> 
    +
    @@ -157,43 +157,65 @@

    Details

    Isotope and adduct features are filtered based on the maximum intensity peak for each molecular formulas.

    Examples

    -
    library(MFassign) -
    #> Loading required package: ggraph
    #> Loading required package: ggplot2
    -## Assign molecular formulas -p <- assignmentParameters('FIE') - -assignment <- assignMFs(peakData,p) -
    #> -#> MFassign v0.7.10 Mon Sep 27 11:19:46 2021
    #> ________________________________________________________________________________
    #> Assignment Parameters: -#> -#> Technique: FIE -#> Max M: 1000 -#> Max MF score: 5 -#> PPM threshold: 5 -#> Relationship limit: 0.001 -#> -#> Adducts: -#> n: [M-H]1-, [M+Cl]1-, [M+K-2H]1-, [M-2H]2-, [M+Cl37]1-, [2M-H]1- -#> p: [M+H]1+, [M+K]1+, [M+Na]1+, [M+K41]1+, [M+NH4]1+, [M+2H]2+, [2M+H]1+ -#> Isotopes: 13C, 18O, 13C2 -#> Transformations: M - [O] + [NH2], M - [OH] + [NH2], M + [H2], M - [H2] + [O], M - [H] + [CH3], M - [H] + [NH2], M - [H] + [OH], M + [H2O], M - [H3] + [H2O], M - [H] + [CHO2], M - [H] + [SO3], M - [H] + [PO3H2]
    #> ________________________________________________________________________________
    #> No. m/z: 9
    #> Calculating correlations
    #> Calculating correlations [24 correlations] [0.1S]
    #> Filtering correlations
    #> Filtering correlations [24 correlations] [0S]
    #> Preparing correlations
    #> Preparing correlations [0S]
    #> Calculating relationships
    #> Calculating relationships [7.3S]
    #> Adduct & isotope assignment
    #> Adduct & isotope assignment [12.2S]
    #> Transformation assignment iteration 1
    #> Transformation assignment iteration 1 [0S]
    #> ________________________________________________________________________________
    #> -#> Complete! [19.6S]
    -## Retrieve assigned data -assigned_data <- metabolyseR::analysisData( - assignedData(assignment), - tibble::tibble(sample = seq_len(nrow(peakData))) - ) - -reduced_data <- metaboMisc::reduce(assigned_data) - -reduced_data -
    #> -#> AnalysisData object containing: -#> -#> Samples: 60 -#> Features: 1 -#> Info: 1 -#>
    +
    library(MFassign)
    +#> Loading required package: ggraph
    +#> Loading required package: ggplot2
    +
    +## Assign molecular formulas
    +p <- assignmentParameters('FIE')
    +
    +assignment <- assignMFs(peakData,p)
    +#> 
    +#> MFassign v0.7.10 Wed Nov 17 09:52:56 2021
    +#> ________________________________________________________________________________
    +#> Assignment Parameters: 
    +#> 
    +#> 	 Technique:		 FIE 
    +#> 	 Max M:			 1000 
    +#> 	 Max MF score:		 5 
    +#> 	 PPM threshold:		 5 
    +#> 	 Relationship limit:	 0.001 
    +#> 
    +#> 	 Adducts: 
    +#> 	 n: [M-H]1-, [M+Cl]1-, [M+K-2H]1-, [M-2H]2-, [M+Cl37]1-, [2M-H]1-
    +#> 	 p: [M+H]1+, [M+K]1+, [M+Na]1+, [M+K41]1+, [M+NH4]1+, [M+2H]2+, [2M+H]1+ 
    +#> 	 Isotopes: 13C, 18O, 13C2 
    +#> 	 Transformations: M - [O] + [NH2], M - [OH] + [NH2], M + [H2], M - [H2] + [O], M - [H] + [CH3], M - [H] + [NH2], M - [H] + [OH], M + [H2O], M - [H3] + [H2O], M - [H] + [CHO2], M - [H] + [SO3], M - [H] + [PO3H2]
    +#> ________________________________________________________________________________
    +#> No. m/z:	9
    +#> Calculating correlations 
    +#> Calculating correlations 	 [24 correlations] [0.1S]
    +#> Filtering correlations 
    +#> Filtering correlations 		 [24 correlations] [0S]
    +#> Preparing correlations 
    +#> Preparing correlations 		 [0S]
    +#> Calculating relationships 
    +#> Calculating relationships 	 [12.4S]
    +#> Adduct & isotope assignment 
    +#> Adduct & isotope assignment 	 [15.7S]
    +#> Transformation assignment iteration 1 
    +#> Transformation assignment iteration 1 	 [0S]
    +#> ________________________________________________________________________________
    +#> 
    +#> Complete! [28.2S]
    +
    +## Retrieve assigned data
    +assigned_data <- metabolyseR::analysisData(
    + assignedData(assignment),
    + tibble::tibble(sample = seq_len(nrow(peakData)))
    + )
    +
    +reduced_data <- metaboMisc::reduce(assigned_data)
    +
    +reduced_data
    +#> 
    +#> AnalysisData object containing:
    +#> 
    +#> Samples: 60 
    +#> Features: 1 
    +#> Info: 1 
    +#> 
    +
    diff --git a/docs/reference/sanitiseTable.html b/docs/reference/sanitiseTable.html index 9029ab6..187209d 100644 --- a/docs/reference/sanitiseTable.html +++ b/docs/reference/sanitiseTable.html @@ -72,7 +72,7 @@ metaboMisc - 0.5.7 + 0.5.8 @@ -120,7 +120,7 @@

    Sanitise a data table

    Sanitise a data table by restricting the number of rows and rounding numeric columns.

    -
    sanitiseTable(x, maxRows = 5000, sigFig = 3)
    +
    sanitiseTable(x, maxRows = 5000, sigFig = 3, maxCharacters = 100)

    Arguments

    @@ -137,22 +137,28 @@

    Arg

    + + + +
    sigFig

    Significant figures with which to round numeric columns

    maxCharacters

    Maximum number of characters allowed in a string before it is truncated

    Examples

    -
    sanitiseTable(iris,maxRows = 10,sigFig = 1) -
    #> Number of rows in table restricted to 10.
    #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species -#> 1 5 4 1 0.2 setosa -#> 2 5 3 1 0.2 setosa -#> 3 5 3 1 0.2 setosa -#> 4 5 3 2 0.2 setosa -#> 5 5 4 1 0.2 setosa -#> 6 5 4 2 0.4 setosa -#> 7 5 3 1 0.3 setosa -#> 8 5 3 2 0.2 setosa -#> 9 4 3 1 0.2 setosa -#> 10 5 3 2 0.1 setosa
    +
    sanitiseTable(iris,maxRows = 10,sigFig = 1)
    +#> Number of rows in table restricted to 10.
    +#>    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
    +#> 1             5           4            1         0.2  setosa
    +#> 2             5           3            1         0.2  setosa
    +#> 3             5           3            1         0.2  setosa
    +#> 4             5           3            2         0.2  setosa
    +#> 5             5           4            1         0.2  setosa
    +#> 6             5           4            2         0.4  setosa
    +#> 7             5           3            1         0.3  setosa
    +#> 8             5           3            2         0.2  setosa
    +#> 9             4           3            1         0.2  setosa
    +#> 10            5           3            2         0.1  setosa
    +
    @@ -125,10 +125,10 @@

    Generate a suitable parallel processing plan

    Examples

    -
    if (FALSE) { -suitableParallelPlan() -} -
    +
    if (FALSE) {
    +suitableParallelPlan()
    +}
    +