Convert Expression Matrix Between Species
Source:R/species_conversion.R
convert_expression_matrix.RdApplies species conversion mapping to an expression matrix, handling one-to-many gene mappings with specified aggregation method.
Usage
convert_expression_matrix(
expr_matrix,
gene_mapping,
handle_duplicates = c("mean", "sum", "max")
)Arguments
- expr_matrix
Matrix or data.frame. Expression data (genes x cells/samples)
- gene_mapping
Data.frame. Output from convert_species_biomart()$mapping
- handle_duplicates
Character. Method for aggregating expression when multiple source genes map to one target gene:
"mean": Average expression (default, conservative)
"sum": Sum expression (appropriate for count data)
"max": Maximum expression
Value
List with elements:
expr_matrix: Converted expression matrix (target genes x cells)
conversion_info: data.frame with mapping details
stats: list with conversion statistics
Examples
if (FALSE) { # \dontrun{
# After obtaining mapping
mapping_result <- convert_species_biomart(
genes = rownames(mouse_expr),
from_species = "Mus_musculus"
)
# Convert expression matrix
converted <- convert_expression_matrix(
expr_matrix = mouse_expr,
gene_mapping = mapping_result$mapping,
handle_duplicates = "mean"
)
# Use converted matrix
human_expr <- converted$expr_matrix
} # }