Conversion to count table function with prevalence filter
get_count_table.RdConversion to count table function with prevalence filter
Usage
get_count_table(
abund.path = NULL,
abund.table = NULL,
sample.id = NULL,
prev.min,
verbatim = TRUE,
msp = NULL
)Source
This function is adapted from the same name function in OneNet package (version 0.3.1), which is licensed under the MIT License. Original copyright (c) 2021-2024 INRAE.
The MIT License text for the original package is as follows:
---
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---Arguments
- abund.path
String. Path to the abundance table
- abund.table
Dataframe. Abundance table, it should have the bacterial species names as first column
- sample.id
String vector. IDs of samples to keep in the final table
- prev.min
Numeric. The value is between 0 and 1 and corresponds to the minimal prevalence threshold of bacterial species to keep in the final table
- verbatim
Boolean. Controls verbosity
- msp
String vector. It indicates bacterial species names, if they are not specified in the abundance table first column
Value
A list containing
- data:
the final count table (tibble)
- prevalences:
a tibble gathering the prevalence of each bacterial species
Examples
tiny_data <- data.frame(
msp_name = c("msp_1", "msp_2", "msp_3", "msp_4"),
SAMPLE1 = c(0, 1.328425e-06, 0, 1.527688e-07),
SAMPLE2 = c(1.251707e-07, 1.251707e-07, 3.985320e-07, 0),
SAMPLE3 = c(0, 0, 4.926046e-09, 5.626392e-06),
SAMPLE4 = c(0, 0, 2.98320e-05, 0)
)
# Applying a prevalence filter of 30% on the new count_table
count_table <- get_count_table(
abund.table = tiny_data,
sample.id = colnames(tiny_data),
prev.min = 0.3
)
#> Preprocessing step output for species prevalence>30% :
#> -from 4 to 3 species
#> -from 50% to 41.7% zero values.