Package 'SpoMAG'

Title: Probability of Sporulation Potential in MAGs
Description: Implements an ensemble machine learning approach to predict the sporulation potential of metagenome-assembled genomes (MAGs) from uncultivated Firmicutes based on the presence/absence of sporulation-associated genes.
Authors: Douglas Terra Machado [aut, cre] (ORCID: <https://orcid.org/0000-0002-6580-7628>), Otávio José Bernardes Brustolini [ctb] (ORCID: <https://orcid.org/0000-0001-8132-9753>), Ellen dos Santos Corrêa [ctb], Ana Tereza Ribeiro Vasconcelos [ctb] (ORCID: <https://orcid.org/0000-0002-4632-2086>)
Maintainer: Douglas Terra Machado <[email protected]>
License: Artistic-2.0
Version: 0.1.0
Built: 2026-05-25 09:31:00 UTC
Source: https://github.com/cran/SpoMAG

Help Index


Build binary presence/absence matrix of sporulation genes

Description

Transforms the output of sporulation_gene_name() into a wide-format matrix indicating the presence (1) or absence (0) of each sporulation-associated gene per genome.

Usage

build_binary_matrix(df)

Arguments

df

A data.frame from sporulation_gene_name() with columns genome_ID and spo_gene_name.

Value

A wide-format binary matrix with genomes in rows and genes in columns.

Examples

# Load package
library(SpoMAG)

# Load example annotation tables
file_spor <- system.file("extdata", "one_sporulating.csv.gz", package = "SpoMAG")
file_aspo <- system.file("extdata", "one_asporogenic.csv.gz", package = "SpoMAG")

# Read files
df_spor <- readr::read_csv(file_spor, show_col_types = FALSE)
df_aspo <- readr::read_csv(file_aspo, show_col_types = FALSE)

# Step 1: Extract sporulation-related genes
genes_spor <- sporulation_gene_name(df_spor)
genes_aspo <- sporulation_gene_name(df_aspo)

# Step 2: Convert to binary matrix
bin_spor <- build_binary_matrix(genes_spor)
bin_aspo <- build_binary_matrix(genes_aspo)

Predict Sporulation Potential

Description

This function predicts the sporulation potential of MAGs using an ensemble learning model. It uses probabilities from Random Forest and SVM classifiers as inputs to a meta-model.

Usage

predict_sporulation(binary_matrix)

Arguments

binary_matrix

A binary matrix (1/0) indicating gene presence/absence for each MAG. Must include a genome_ID column.

Value

A tibble with predicted class and probability of sporulation for each genome.

Examples

# Load package
library(SpoMAG)

# Load example annotation tables
file_spor <- system.file("extdata", "one_sporulating.csv.gz", package = "SpoMAG")
file_aspo <- system.file("extdata", "one_asporogenic.csv.gz", package = "SpoMAG")

# Read files
df_spor <- readr::read_csv(file_spor, show_col_types = FALSE)
df_aspo <- readr::read_csv(file_aspo, show_col_types = FALSE)

# Step 1: Extract sporulation-related genes
genes_spor <- sporulation_gene_name(df_spor)
genes_aspo <- sporulation_gene_name(df_aspo)

# Step 2: Convert to binary matrix
bin_spor <- build_binary_matrix(genes_spor)
bin_aspo <- build_binary_matrix(genes_aspo)

# Step 3: Predict using ensemble model (preloaded in package)

result_spor <- predict_sporulation(bin_spor)
result_aspo <- predict_sporulation(bin_aspo)

Identify Sporulation-Associated Genes

Description

This function identifies sporulation-associated genes in a genome annotation data frame. It searches for gene names and KEGG Orthology identifiers related to sporulation steps and returns a data frame with annotated sporulation genes and a consensus name.

Usage

sporulation_gene_name(df)

Arguments

df

A data frame containing MAG annotation with the columns 'Preferred_name', 'KEGG_ko', and 'genome_ID'.

Value

A data frame of sporulation-associated genes with standardized names and spo_process tags.

Examples

# Load package
library(SpoMAG)
# Load example annotation tables
file_spor <- system.file("extdata", "one_sporulating.csv.gz", package = "SpoMAG")
file_aspo <- system.file("extdata", "one_asporogenic.csv.gz", package = "SpoMAG")

# Read files
df_spor <- readr::read_csv(file_spor, show_col_types = FALSE)
df_aspo <- readr::read_csv(file_aspo, show_col_types = FALSE)

# Step 1: Extract sporulation-related genes
genes_spor <- sporulation_gene_name(df_spor)
genes_aspo <- sporulation_gene_name(df_aspo)