MoussaMap is an R package for building interactive heatmaps from an expression matrix and cell metadata.
It is designed to:
- read a gene-by-cell expression matrix and matching cell metadata
- optionally filter genes and cells from CSV selection files
- group cells into hierarchical paths such as
class -> subclass -> cluster - average expression within each group
- optionally normalize or scale the grouped matrix
- return an interactive
heatmaplyplot with annotation bars and a cleaned legend
install.packages("pak")
pak::pkg_install("Fnorgh/MoussaMap")Or with remotes:
install.packages("remotes")
remotes::install_github("Fnorgh/MoussaMap", upgrade = "never")library(MoussaMap)
result <- MoussaMap(
expression_matrix = "expr_matrix.csv",
metadata = "metadata.csv",
normalization = "none"
)
result$plotThe function returns a list with:
result$plot: the interactive heatmapresult$error: an error message if something failed
You must provide two CSV files.
Passed to expression_matrix.
Requirements:
- rows are genes
- columns are cells
- the first column contains gene names
Example:
gene,cellA,cellB,cellC
MS4A1,0,1.2,0.3
LST1,4.5,0.1,2.2
IL7R,2.0,0.0,1.1Passed to metadata.
Requirements:
- the first column contains cell IDs
- those cell IDs must match the expression matrix column names
- the remaining columns are hierarchy levels ordered from broad to fine
Example:
cell_id,class,subclass,cluster
cellA,Immune,Tcell,Tcell_1
cellB,Immune,Bcell,Bcell_2
cellC,Glia,Microglia,Micro_3Important details:
- the first metadata column is treated as the cell ID column even if it has a different name
- if the first metadata column has no name, the function renames it to
cell_id - all metadata columns after the first are treated as grouping levels
Optional path to a one-column CSV listing genes to keep.
Example:
MS4A1
LST1
IL7ROptional path to a one-column CSV listing cells to keep.
Example:
cellA
cellCOptional path to a CSV containing the finest grouping level to use.
Example:
level
clusterOptional path to a CSV listing the metadata columns to use and their order.
Example:
class
subclass
clusterIf group_order is provided, the heatmap keeps row clustering and hides the column dendrogram.
MoussaMap(
expression_matrix,
metadata,
gene_selection = NULL,
cell_selection = NULL,
group_by = NULL,
group_order = NULL,
group_by_level = NULL,
top_var_features = NULL,
varfeat_method = "vst",
colorscale = "viridis",
normalization = "none",
width = 1000,
height = 800
)top_var_features: keep only the top variable genes after averagingvarfeat_method: method passed to Seurat for variable feature selectiongroup_by_level: directly set the finest grouping column without using a file
Use the normalization argument.
"none": no transform"log2": applylog2(expr + 1)before averaging"scale": z-score each gene after averaging"log2_scale": log-transform before averaging, then z-score after averaging"max": divide each gene row by its maximum value after averaging
Notes:
- scaling is done row-wise by gene
NAandInfvalues are replaced with0before plotting
Use the colorscale argument.
"viridis"default"plasma""Blues""Reds"
These control the heatmap intensity colors for expression values.
The output plot includes:
- clustered genes
- grouped cell columns
- annotation bars for each metadata hierarchy level used
- cleaned legend labels so users see category names instead of hex colors
- hover text showing annotation variable and value
library(MoussaMap)
result <- MoussaMap(
expression_matrix = "expr_matrix.csv",
metadata = "metadata.csv",
gene_selection = "selected_genes.csv",
cell_selection = "selected_cells.csv",
group_by = "group_by_level.csv",
group_order = "group_order.csv",
top_var_features = 200,
varfeat_method = "vst",
colorscale = "viridis",
normalization = "log2_scale",
width = 1200,
height = 900
)
result$plotlibrary(MoussaMap)
result <- MoussaMap(
expression_matrix = "expr_matrix.csv",
metadata = "metadata.csv",
)
result$plot