Conversion to count table function with prevalence filter (Extracted from OneNet package)
get_count_table.RdConversion to count table function with prevalence filter (Extracted from OneNet package)
Usage
get_count_table(
abund.path = NULL,
abund.table = NULL,
sample.id = NULL,
prev.min,
verbatim = TRUE,
msp = NULL
)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.