View source: R/build_binary_matrix.R
| build_binary_matrix | R Documentation |
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.
build_binary_matrix(df)
df |
A data.frame from |
A wide-format binary matrix with genomes in rows and genes in columns.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.