| Title: | Kraken Confidence Scores for Reliable Domain-Specific Microbiota Inference and Discovery |
|---|---|
| Description: | Provides a comprehensive framework for analyzing Kraken2 metagenomic classification using multiple confidence scores. karioCaS implements a robust comparative approach to evaluate taxonomic stability across different stringency levels, facilitating the identification of reliable microbiota components and the discovery of potentially novel or unrepresented species. A key innovation is its domain-specific analysis, separately processing Bacteria, Archaea, Eukaryota, and Viruses to ensure balanced visibility of all biological domains. Includes high-quality visualization tools for retention rates, shared taxa (Upset plots), and stability heatmaps. |
| Authors: | Thiago Parente [aut, cre] (ORCID: <https://orcid.org/0000-0001-7501-726X>), Fiocruz [fnd], IOC-Fiocruz [fnd], CAPES [fnd] |
| Maintainer: | Thiago Parente <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.99.16 |
| Built: | 2026-09-28 22:20:33 UTC |
| Source: | https://github.com/BiocStaging/karioCaS |
For each biological group (inferred from sample names by stripping trailing
digits, e.g. SAMPLE33, SAMPLE34 -> SAMPLE), draws an
UpSet plot comparing which taxa (at tax_level) are present across the
samples of the group, per Domain. This separates the core taxa
(present in every sample) from unique/rare taxa (present in one or a
few samples) - the expected pattern for pathogens and false positives. A
membership TSV (presence matrix plus N_Samples and a
Core/Shared/Unique Category) is written alongside each plot.
group_upset(project_dir, tax_level = "Species", CS = NULL, export = TRUE)group_upset(project_dir, tax_level = "Species", CS = NULL, export = TRUE)
project_dir |
Path to the project root. |
tax_level |
Taxonomic rank to compare (default: |
CS |
Confidence Score to analyse. |
export |
Logical (default |
By default the analysis uses the final mosaic from
retrieve_selected_taxa(); set CS to compare at a single
Confidence Score from the imported data instead.
Groups with a single sample cannot be compared and are skipped with a log
message; if no group has at least two samples, the function warns that
nothing was generated. Category is "Core" when a taxon is
present in every sample of the group, "Unique" when it is present
in exactly one, and "Shared" otherwise.
A kariocas_result object. $data is the
membership table: one row per group, domain and taxon, with
N_Samples, Category, Unique_Sample and one 0/1
column per sample. $plots holds one UpSetR plot per group
and domain (printing an element draws it) and $paths lists the
files written when export = TRUE.
# The toy project has a single sample; add a second sample of the same # group (a copy of SAMPLE01 named SAMPLE02) so they can be compared. toy_project <- file.path(tempdir(), "toy_karioCaS_groups") in_dir <- file.path(toy_project, "000_mpa_original") dir.create(in_dir, recursive = TRUE, showWarnings = FALSE) src <- list.files( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), full.names = TRUE ) file.copy(src, in_dir) file.copy(src, file.path(in_dir, sub("SAMPLE01", "SAMPLE02", basename(src)))) import_karioCaS(toy_project) # Core vs unique genera across the samples of each group, at CS 40 res <- group_upset(toy_project, tax_level = "Genus", CS = 40, export = FALSE) res table(res$data$Domain, res$data$Category) unlink(toy_project, recursive = TRUE)# The toy project has a single sample; add a second sample of the same # group (a copy of SAMPLE01 named SAMPLE02) so they can be compared. toy_project <- file.path(tempdir(), "toy_karioCaS_groups") in_dir <- file.path(toy_project, "000_mpa_original") dir.create(in_dir, recursive = TRUE, showWarnings = FALSE) src <- list.files( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), full.names = TRUE ) file.copy(src, in_dir) file.copy(src, file.path(in_dir, sub("SAMPLE01", "SAMPLE02", basename(src)))) import_karioCaS(toy_project) # Core vs unique genera across the samples of each group, at CS 40 res <- group_upset(toy_project, tax_level = "Genus", CS = 40, export = FALSE) res table(res$data$Domain, res$data$Category) unlink(toy_project, recursive = TRUE)
Creates Relative Abundance ( Confidence Score. "Elite" survivors are clustered by similarity, while lost taxa are aggregated into "Loss Groups" at the bottom. Handles domains with zero survivors at the target CS (showing only loss groups).
heatmaps_karioCaS( project_dir, analysis_rank = "Genus", confidence_score = NULL, top_n = 20, export = TRUE )heatmaps_karioCaS( project_dir, analysis_rank = "Genus", confidence_score = NULL, top_n = 20, export = TRUE )
project_dir |
Path to the project root. |
analysis_rank |
Taxonomic rank to analyze (default: |
confidence_score |
Target CS to define survivors, as a Kraken fraction
( |
top_n |
Number of top survivors to display individually (default: 20). |
export |
Logical (default |
A kariocas_result object. $data holds the
plotted values (one row per sample, domain, taxon or loss group and CS,
with Counts, Rel_Abund and the Target_CS used),
$plots one ggplot heatmap per sample and $paths the
files written when export = TRUE.
For each sample and domain, a taxon's reads at analysis_rank are
the count of its own MPA row, which already includes the reads classified
to lower ranks. The top_n taxa with most reads at the target CS are
shown individually. The remaining taxa are aggregated: taxa present at a CS
below the target but absent at the next CS form a row
"Recovered only in CSxx"; taxa still present at the target CS but not
among the top_n form a row "Lowest abundance ... in CSxx".
Rel_Abund is the reads of a row divided by the total reads of all
taxa of that domain at analysis_rank at the same CS, times 100.
Individual taxa are ordered by hierarchical clustering (Euclidean distance,
complete linkage) of their relative-abundance profiles across CS.
# Copy the bundled toy project to a temporary folder and import it toy_project <- file.path(tempdir(), "toy_karioCaS") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) import_karioCaS(toy_project) # Species-level heatmap at CS 50, top 15 taxa, kept in memory res <- heatmaps_karioCaS( toy_project, analysis_rank = "Species", confidence_score = 50, top_n = 15, export = FALSE ) res res$plots[[1]] unlink(toy_project, recursive = TRUE)# Copy the bundled toy project to a temporary folder and import it toy_project <- file.path(tempdir(), "toy_karioCaS") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) import_karioCaS(toy_project) # Species-level heatmap at CS 50, top 15 taxa, kept in memory res <- heatmaps_karioCaS( toy_project, analysis_rank = "Species", confidence_score = 50, top_n = 15, export = FALSE ) res res$plots[[1]] unlink(toy_project, recursive = TRUE)
Reads Kraken2 MPA-style reports from the 000_mpa_original folder.
Parses filenames like SAMPLE_CSXX.mpa (e.g., PILO_CS09.mpa).
Generates a detailed log file for traceability and saves a
TreeSummarizedExperiment object for downstream analysis.
import_karioCaS(project_dir)import_karioCaS(project_dir)
project_dir |
Path to the project root. Must contain a
|
Each report becomes one column of the count matrix, named
SAMPLE_CSxx; the sample name and the CS (as an integer percentage,
e.g. CS09 = 90) are stored in colData(). Each distinct
taxonomic path becomes one row: taxa absent from a report get a count of 0
in that column, and identical paths within a report are summed. The lineage
is split into eight rank columns (Domain to Species) in rowData(),
together with Rank, the lowest rank present in the path. No
normalisation or transformation is applied; counts are the read counts of
the reports, which in MPA format are cumulative (a genus count includes the
reads of its species). The object and a tab-separated copy of the matrix are
saved to <project_dir>/001_imported_matrix/, where the other steps
read it from.
Invisibly returns the TreeSummarizedExperiment object.
# Copy the bundled toy reports to a temporary project folder toy_project <- file.path(tempdir(), "toy_karioCaS_import") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) tse <- import_karioCaS(toy_project) tse SummarizedExperiment::colData(tse) unlink(toy_project, recursive = TRUE)# Copy the bundled toy reports to a temporary project folder toy_project <- file.path(tempdir(), "toy_karioCaS_import") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) tse <- import_karioCaS(toy_project) tse SummarizedExperiment::colData(tse) unlink(toy_project, recursive = TRUE)
Every analysis function of karioCaS returns an object of class
kariocas_result. It bundles the computed table(s), the generated
plots and, when export = TRUE, the paths of the files written to
the project folder. Elements are accessed with $.
kariocas_result( step, data = NULL, plots = list(), paths = character(0), output_dir = NULL ) ## S3 method for class 'kariocas_result' print(x, ...)kariocas_result( step, data = NULL, plots = list(), paths = character(0), output_dir = NULL ) ## S3 method for class 'kariocas_result' print(x, ...)
step |
Character. Name of the step, e.g. |
data |
A data frame with the computed results, or |
plots |
A named list of |
paths |
Character vector of files written (empty if nothing exported). |
output_dir |
Output folder, or |
x |
A |
... |
Ignored. |
A list of class kariocas_result with elements step,
data, plots, paths and output_dir.
print(kariocas_result): Compact summary of a result object.
res <- kariocas_result( step = "demo", data = data.frame(x = 1:3), plots = list(), paths = character(0), output_dir = NULL ) res res$datares <- kariocas_result( step = "demo", data = data.frame(x = 1:3), plots = list(), paths = character(0), output_dir = NULL ) res res$data
Saturation analysis: progressively raises a per-taxon read-count cutoff and
tracks how many taxa survive, on a log read axis. By default it draws one
group overlay per biological group (every sample a faint line, group
mean highlighted) and marks each domain's median optimal minimum
reads - the elbow of the saturation curve, found with the same engine used
for the optimal CS - as a dashed line. The per-sample optimal-reads values are
written to Reads_Audit_<rank>.tsv/.rds, giving a quantitative
threshold for excluding low-abundance background/false-positive taxa.
reads_per_taxa( project_dir, analysis_level = "Species", method = c("kneedle", "postcliff", "segmented"), detail_samples = NULL, export = TRUE )reads_per_taxa( project_dir, analysis_level = "Species", method = c("kneedle", "postcliff", "segmented"), detail_samples = NULL, export = TRUE )
project_dir |
Path to the project root. |
analysis_level |
Taxonomic rank to analyze (default: |
method |
Elbow strategy for the optimal reads. One of |
detail_samples |
Which samples to also render as detailed per-sample
saturation panels. |
export |
Logical (default |
The optimal reads is computed per Confidence Score, since the saturation curve changes with CS; read it off at your chosen optimal CS (Step 002).
A kariocas_result object with $data, the
optimal-reads audit table (one row per sample, CS, domain and read cutoff),
$plots, a named list of patchwork figures (one saturation
overlay per group and CS, plus detailed per-sample panels when requested)
and $paths, the files written when export = TRUE.
For each sample, CS and domain, the taxa at analysis_level are
counted at increasing minimum-read cutoffs (1, 2, 3, 4, 5, 7, 10, then
1, 2, 3, 5 and 7 up to just past the largest count).
Taxa_Count is the number of taxa with at least Cutoff reads,
where a taxon's reads are the count of its own MPA row (which already
includes reads classified to lower ranks). Pct_Retained is
Taxa_Count as a percentage of the count at the lowest cutoff, and
Step_Loss_Pct the loss since the previous cutoff. The optimal
minimum reads (Primary SI) is the elbow of this curve, found with the same
engine as in taxa_retention on a read axis;
with "kneedle", the more conservative post-cliff cutoff is reported
as Secondary SI when it is larger.
# Copy the bundled toy project to a temporary folder and import it toy_project <- file.path(tempdir(), "toy_karioCaS") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) import_karioCaS(toy_project) # Saturation overlays + optimal minimum reads (Kneedle), in memory only res <- reads_per_taxa(toy_project, export = FALSE) res head(res$data) res$plots[[1]] unlink(toy_project, recursive = TRUE)# Copy the bundled toy project to a temporary folder and import it toy_project <- file.path(tempdir(), "toy_karioCaS") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) import_karioCaS(toy_project) # Saturation overlays + optimal minimum reads (Kneedle), in memory only res <- reads_per_taxa(toy_project, export = FALSE) res head(res$data) res$plots[[1]] unlink(toy_project, recursive = TRUE)
Creates a "biological mosaic" for each sample using the
karioCaS_TSE.rds object from Step 001 and, optionally, the optimal
thresholds computed earlier: the optimal Confidence Score (Stability Index
audit from taxa_retention(), Step 002) and the optimal minimum reads
(Reads_Audit from reads_per_taxa(), Step 003). Both the
CS_* and reads_min_* arguments accept "auto",
"secondary", or a manual numeric value per domain. The optimal reads is
looked up at each domain's resolved CS, so the mosaic combines both data-driven
thresholds automatically. The mosaic always retains all taxonomic
ranks present in the input (as an MPA profile does); enforces a strict
> 0 read filter.
retrieve_selected_taxa( project_dir, tax_level = NULL, CS_A = "auto", reads_min_A = 0, CS_B = "auto", reads_min_B = 0, CS_E = "auto", reads_min_E = 0, CS_V = "auto", reads_min_V = 0, export = TRUE )retrieve_selected_taxa( project_dir, tax_level = NULL, CS_A = "auto", reads_min_A = 0, CS_B = "auto", reads_min_B = 0, CS_E = "auto", reads_min_E = 0, CS_V = "auto", reads_min_V = 0, export = TRUE )
project_dir |
Path to the project root. |
tax_level |
Which rank's optimization audit the |
CS_A |
Character or numeric. CS for Archaea:
|
reads_min_A |
Minimum reads for Archaea: |
CS_B |
Character or numeric. CS for Bacteria. Default: |
reads_min_B |
Minimum reads for Bacteria. Default: 0. |
CS_E |
Character or numeric. CS for Eukaryota. Default: |
reads_min_E |
Minimum reads for Eukaryota. Default: 0. |
CS_V |
Character or numeric. CS for Viruses. Default: |
reads_min_V |
Minimum reads for Viruses. Default: 0. |
export |
Logical (default |
"auto" and "secondary" read the audit files exported by
taxa_retention and reads_per_taxa; if the
required file is missing the function stops with an explanation rather
than silently applying no threshold. When the audit exists but has no
optimal value for a given sample and domain (typically a domain with too
few taxa to fit a curve), CS 0 or 0 minimum reads is used for that domain
and a single warning lists every such case.
A kariocas_result object. $data is the mosaic
in long format: one row per sample and taxon, with the read
Counts at the selected CS, the Domain, the CS and
Min_Reads applied, and where each threshold came from
(CS_Source, Min_Reads_Source). $plots is empty and
$paths lists the files written when export = TRUE.
# Copy the bundled toy project to a temporary folder and import it toy_project <- file.path(tempdir(), "toy_karioCaS") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) import_karioCaS(toy_project) # "auto" thresholds come from the exported audits of the previous steps taxa_retention(toy_project) reads_per_taxa(toy_project) # Data-driven CS and minimum reads for Bacteria and Archaea, # manual thresholds for Eukaryota and Viruses mosaic <- retrieve_selected_taxa( toy_project, CS_B = "auto", reads_min_B = "auto", CS_A = "auto", reads_min_A = "auto", CS_E = 40, reads_min_E = 10, CS_V = 0, reads_min_V = 0 ) mosaic unique(mosaic$data[, c("Domain", "CS", "CS_Source", "Min_Reads")]) unlink(toy_project, recursive = TRUE)# Copy the bundled toy project to a temporary folder and import it toy_project <- file.path(tempdir(), "toy_karioCaS") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) import_karioCaS(toy_project) # "auto" thresholds come from the exported audits of the previous steps taxa_retention(toy_project) reads_per_taxa(toy_project) # Data-driven CS and minimum reads for Bacteria and Archaea, # manual thresholds for Eukaryota and Viruses mosaic <- retrieve_selected_taxa( toy_project, CS_B = "auto", reads_min_B = "auto", CS_A = "auto", reads_min_A = "auto", CS_E = 40, reads_min_E = 10, CS_V = 0, reads_min_V = 0 ) mosaic unique(mosaic$data[, c("Domain", "CS", "CS_Source", "Min_Reads")]) unlink(toy_project, recursive = TRUE)
Creates stacked bar plots showing resolution efficiency between a Parent Rank
and a Child Rank (how much of each parent clade's reads are resolved down to
the child rank versus remaining parent-exclusive). Uses max() for
parent aggregation to prevent double-counting of children in cumulative data.
taxa_resolution( project_dir, parent_level = "Genus", child_level = "Species", CS = NULL, top_n = 10, export = TRUE )taxa_resolution( project_dir, parent_level = "Genus", child_level = "Species", CS = NULL, top_n = 10, export = TRUE )
project_dir |
Path to the project root. |
parent_level |
Name of the parent rank (default: |
child_level |
Name of the child rank (default: |
CS |
Confidence Score to analyse. |
top_n |
Number of top taxa to display per domain (default: 10). |
export |
Logical (default |
By default the analysis runs on the final mosaic produced by
retrieve_selected_taxa (004_final_mosaic/), i.e. the
data-driven high-confidence selection - one figure per sample. Alternatively,
set CS to analyse the raw imported data at a single Confidence Score.
A kariocas_result object. $data holds, for
each sample, domain and top parent taxon, the parent's cumulative reads
(Parent_Cumulative_Total), the reads resolved to the child rank
(Child_Sum_Resolved) and the parent-exclusive reads
(Parent_Exclusive); $plots one patchwork figure per
sample; $paths the files written when export = TRUE.
MPA counts are cumulative, so a parent row (e.g. a genus) already includes
the reads of its children (its species). For the top_n parent taxa
with most reads in each domain: Parent_Cumulative_Total is the count
of the parent's own row; Child_Sum_Resolved is the sum of its
children's rows at child_level, i.e. the reads resolved down to the
child rank; Parent_Exclusive is
Parent_Cumulative_Total - Child_Sum_Resolved (floored at 0), the
reads classified to the parent but not resolved to the child rank.
# Copy the bundled toy project to a temporary folder and import it toy_project <- file.path(tempdir(), "toy_karioCaS") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) import_karioCaS(toy_project) # Genus vs Species resolution of the imported data at CS 40, in memory res <- taxa_resolution(toy_project, CS = 40, export = FALSE) res head(res$data) res$plots[[1]] unlink(toy_project, recursive = TRUE)# Copy the bundled toy project to a temporary folder and import it toy_project <- file.path(tempdir(), "toy_karioCaS") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) import_karioCaS(toy_project) # Genus vs Species resolution of the imported data at CS 40, in memory res <- taxa_resolution(toy_project, CS = 40, export = FALSE) res head(res$data) res$plots[[1]] unlink(toy_project, recursive = TRUE)
Executes taxa retention analysis based on Confidence Score (Kraken/Bracken)
and, in the same step, computes the objective optimal CS (Stability Index, SI)
for each domain. By default it produces a single, low-clutter group
overlay per biological group: every sample of the group is drawn as a faint
line with the group mean (SD) highlighted and each domain's median
optimal CS marked with a dashed line, faceted by Domain. It also writes the
machine-readable SI audit (SI_Audit_<rank>.tsv/.rds) used by
retrieve_selected_taxa. Detailed per-sample panels (all ranks,
taxa vs reads) are written only on request.
taxa_retention( project_dir, tax_level = "Species", method = c("kneedle", "postcliff", "segmented", "dynamic", "manual"), manual_toll = 1, detail_samples = NULL, export = TRUE )taxa_retention( project_dir, tax_level = "Species", method = c("kneedle", "postcliff", "segmented", "dynamic", "manual"), manual_toll = 1, detail_samples = NULL, export = TRUE )
project_dir |
Root path of the project. |
tax_level |
Taxonomic rank used for the group overlay and SI
(default: |
method |
Optimal-CS strategy. One of |
manual_toll |
Numeric or named list. Acceptable step-wise loss percentage,
used only when |
detail_samples |
Which samples to also render as detailed per-sample
panels. |
export |
Logical (default |
Groups are inferred from sample names by stripping trailing digits
(e.g. SAMPLE33, SAMPLE34 both belong to group SAMPLE).
The optimal CS is found with a multi-strategy engine: "kneedle"
(default, parameter-free elbow detection), "postcliff" (a more
conservative threshold past the steepest drop), "segmented"
(broken-stick regression), "dynamic", or "manual".
A kariocas_result object with $data, the SI
audit table (one row per sample, domain and CS, with the retention
percentages and the Stability Index tags), $plots, a named list of
patchwork figures (one group overlay per biological group, plus the
detailed per-sample panels when requested) and $paths, the files
written when export = TRUE.
For each sample and domain, at each CS:
Taxa_Count: number of distinct taxa at tax_level
detected with at least one read.
Pct_Retained: Taxa_Count as a percentage of its
maximum across CS values (normally the value at CS 0).
Step_Loss_Pct: percentage points of Pct_Retained lost
since the previous CS.
The optimal CS (Primary SI) is then located on the Pct_Retained
curve. "kneedle": the CS at which the curve lies furthest below the
straight line joining its first and last points (falling back to the
steepest single drop if the curve is not convex). "postcliff": the
first CS, at or after the steepest drop, whose Step_Loss_Pct is at
most a tolerance , where and
are the mean and SD of the step losses at CS 50.
"segmented": the breakpoint minimising the total residual sum of
squares of two straight-line fits. "dynamic": the first CS above the
lowest one whose step loss is within the same tolerance. "manual":
the first CS above the lowest one whose step loss is within
manual_toll (a single value, or a named list per domain). When no CS
qualifies, the highest CS is used. A Secondary SI, a stricter alternative,
is also reported by "kneedle" (the post-cliff value, when stricter
than the elbow), "dynamic" (the next CS whose step loss is at most
) and "manual" (the next CS whose step loss
is at most 0.2). A domain needs at least three CS values and some loss of
taxa to be assessed.
In the detailed per-sample panels, curves are expressed relative to CS 0: taxa at each rank (distinct taxa detected), reads classified to that rank (the sum of the rank's own MPA rows, which already include the reads classified to lower ranks) and total reads of the domain (the domain row).
# Copy the bundled toy project to a temporary folder and import it toy_project <- file.path(tempdir(), "toy_karioCaS") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) import_karioCaS(toy_project) # Retention curves + optimal CS (Kneedle), results kept in memory only res <- taxa_retention(toy_project, export = FALSE) res head(res$data) names(res$plots) res$plots[[1]] unlink(toy_project, recursive = TRUE)# Copy the bundled toy project to a temporary folder and import it toy_project <- file.path(tempdir(), "toy_karioCaS") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) import_karioCaS(toy_project) # Retention curves + optimal CS (Kneedle), results kept in memory only res <- taxa_retention(toy_project, export = FALSE) res head(res$data) names(res$plots) res$plots[[1]] unlink(toy_project, recursive = TRUE)
"karioCaS never are upset!" Generates UpSet plots showing taxon persistence across Confidence Score levels, for a single taxonomic rank, with detailed logging. One plot per sample and domain is written to a per-sample subfolder.
upset_kariocas(project_dir, tax_level = "Species", export = TRUE)upset_kariocas(project_dir, tax_level = "Species", export = TRUE)
project_dir |
Path to the project root. |
tax_level |
Taxonomic rank to analyze (default: |
export |
Logical (default |
A kariocas_result object. $data is the
presence/absence table behind the plots: one row per sample, domain and
taxon, one CSxx column per Confidence Score (1 = detected with
at least one read at that CS) and N_CS, the number of CS levels
at which the taxon is detected. $plots holds one UpSetR
plot per sample and domain; printing an element draws it on the current
device. $paths lists the PDFs written when export = TRUE.
If a plot cannot be drawn, a warning names it and it is not counted as a
success.
# Copy the bundled toy project to a temporary folder and import it toy_project <- file.path(tempdir(), "toy_karioCaS") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) import_karioCaS(toy_project) # Genus persistence across Confidence Scores, kept in memory res <- upset_kariocas(toy_project, tax_level = "Genus", export = FALSE) res head(res$data) res$plots[["SAMPLE01_Bacteria_Genus"]] unlink(toy_project, recursive = TRUE)# Copy the bundled toy project to a temporary folder and import it toy_project <- file.path(tempdir(), "toy_karioCaS") dir.create(toy_project, showWarnings = FALSE) file.copy( system.file("extdata", "your_project_name", "000_mpa_original", package = "karioCaS" ), toy_project, recursive = TRUE ) import_karioCaS(toy_project) # Genus persistence across Confidence Scores, kept in memory res <- upset_kariocas(toy_project, tax_level = "Genus", export = FALSE) res head(res$data) res$plots[["SAMPLE01_Bacteria_Genus"]] unlink(toy_project, recursive = TRUE)