### Install Cell Marker Accordion R Package Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Instructions to install the cellmarkeraccordion R package from GitHub. This requires the devtools package to be installed first. The installation includes downloading dependencies. ```bash install.packages("devtools") library(devtools) install_github("TebaldiLab/cellmarkeraccordion", dependencies = TRUE) ``` -------------------------------- ### Annotate with Count Matrices Instead of Seurat Objects (R) Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt This example demonstrates how to use Cell Marker Accordion with raw count matrices when not using a Seurat workflow. It involves extracting counts and cluster information, performing the annotation, and accessing the results from the list output. ```r # Extract counts and cluster information raw_counts <- GetAssayData(data, assay = "RNA", slot = "counts") clusters <- data.table( cell = rownames(data@meta.data), cluster = data@meta.data$seurat_clusters ) # Perform annotation with matrix input output <- accordion( raw_counts, assay = "RNA", species = "Human", tissue = "blood", cluster_info = clusters, annotation_resolution = "cluster", max_n_marker = 30, include_detailed_annotation_info = TRUE, plot = TRUE ) # Access results from list output scaled_matrix <- output[["scaled_matrix"]] cluster_annotation <- output[["cluster_annotation"]] detailed_info <- output[["accordion"]] ``` -------------------------------- ### Load Custom Marker Genes for Integration (R) Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Loads a pre-defined example dataset of custom marker genes for integration into the Accordion database. This step prepares the data for the `marker_database_integration` function. It's essential to inspect the structure and content of this loaded data before proceeding. ```r load(system.file("extdata", "custom_markers_to_integrate.rda", package = "cellmarkeraccordion")) head(custom_markers_to_integrate, 10) ``` -------------------------------- ### Load Seurat Object for CellMarkerAccordion Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Loads a pre-processed Seurat object from the cellmarkeraccordion package's example data. This object is required as input for the accordion_disease function. ```r load(system.file("extdata", "bone_marrow_data.rda", package = "cellmarkeraccordion")) ``` -------------------------------- ### Annotate Cell Types with Accordion Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt Annotates cell types in a given single-cell dataset using the accordion function. It takes the dataset and several parameters to guide the annotation process, such as species, tissue, and annotation resolution. The function returns the annotated dataset. ```r mouse_bm_data <- accordion( mouse_bm_data, assay = "RNA", species = "Mouse", tissue = "bone marrow", annotation_resolution = "cluster", max_n_marker = 30, allow_unknown = FALSE, include_detailed_annotation_info = FALSE, plot = FALSE ) ``` -------------------------------- ### List Available Resources Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt Queries the cellmarkeraccordion databases to list available biological resources such as tissues, cell types, and diseases. Functions like list_tissues, list_celltypes, list_diseases, list_aberrant_celltypes, and list_disease_tissues allow users to explore the data scope. ```r # List available tissues for human blood analysis available_tissues <- list_tissues(species = "Human") available_tissues[1:20] # List cell types available for specific tissue blood_celltypes <- list_celltypes(species = "Human", tissue = "blood") # List diseases in disease database available_diseases <- list_diseases() # List aberrant cell types for specific disease aml_celltypes <- list_aberrant_celltypes(disease = "acute myeloid leukemia") # List tissues available in disease database disease_tissues <- list_disease_tissues(species = "Human") ``` -------------------------------- ### Load Pathway Marker Table Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md This code snippet loads a dataset containing gene markers associated with specific biological pathways. It utilizes `system.file` to access the `marker_table_pathway.rda` file from the `cellmarkeraccordion` package and `head` to display the initial entries, illustrating 'pathway' and 'genes' columns. ```bash load(system.file("extdata", "marker_table_pathway.rda", package = "cellmarkeraccordion")) head(marker_table_pathway, 10) ``` -------------------------------- ### Integrate Custom Markers with Database Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt Integrates user-provided custom markers into the cellmarkeraccordion database using the marker_database_integration function. This allows for enhanced annotation by combining external marker lists with the package's built-in resources. The function requires specifying column names for various marker attributes. ```r # Load custom markers to integrate load(system.file("extdata", "custom_markers_to_integrate.rda", package = "cellmarkeraccordion")) head(custom_markers_to_integrate, 10) # species Uberon_tissue CL_celltype marker resource # Mouse brain glutamatergic neuron Satb2 custom_set_1 # Mouse brain glutamatergic neuron Satb2 custom_set_2 # Mouse brain glutamatergic neuron Slc17a6 custom_set_1 # Integrate with healthy database database_integrated <- marker_database_integration( marker_table = custom_markers_to_integrate, database = "healthy", species_column = "species", tissue_column = "Uberon_tissue", celltype_column = "CL_celltype", marker_column = "marker", marker_type_column = "marker_type", resource_column = "resource" ) ``` -------------------------------- ### Load Custom Retinal Cell Type Markers Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md This code snippet loads a pre-defined dataset of marker genes associated with retinal cell types. It uses `system.file` to locate the data within the `cellmarkeraccordion` package and `head` to display the first few rows of the marker table, showing columns like 'cell_type' and 'marker'. ```bash load(system.file("extdata", "retina_markers.rda", package = "cellmarkeraccordion")) head(retina_markers) ``` -------------------------------- ### Load Processed Seurat Object Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md This command loads a pre-processed Seurat object containing retinal data. The `load` function is used to access the `.rda` file from the `cellmarkeraccordion` package's extension data directory, making the `retinal_data` object available for subsequent analysis. ```bash load(system.file("extdata", "retinal_data.rda", package = "cellmarkeraccordion")) ``` -------------------------------- ### Annotate Spatial Transcriptomics Data with Custom Markers (R) Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt This code shows how to annotate spatial transcriptomics data (like MERFISH) using Cell Marker Accordion with a custom integrated database. It includes steps for loading data, performing annotation, and visualizing the spatial annotation results using ggplot2. ```r # Load MERFISH mouse brain dataset load(system.file("extdata", "brain_data.rda", package = "cellmarkeraccordion")) # Annotate using integrated database with custom markers brain_data <- accordion( brain_data, assay = "SCT", database = database_integrated, species = "Mouse", tissue = "brain", annotation_resolution = "cluster", max_n_marker = 30, include_detailed_annotation_info = FALSE, plot = FALSE, allow_unknown = FALSE, annotation_name = "integrated_database" ) # Visualize spatial annotation library(ggplot2) ggplot(brain_data@meta.data, aes(x = x, y = -y, color = integrated_database_per_cluster)) + geom_point(size = 1) + theme_classic() + theme( axis.title = element_blank(), axis.text = element_blank(), axis.ticks = element_blank(), axis.line = element_blank() ) ``` -------------------------------- ### Annotate Brain Data with Integrated Database (R) Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt This snippet demonstrates how to use the Cell Marker Accordion function to annotate brain data with an integrated database. It assumes the brain_data object and database_integrated are loaded. The output includes visualization of the annotation results. ```r load(system.file("extdata", "brain_data.rda", package = "cellmarkeraccordion")) brain_data <- accordion( brain_data, assay = "SCT", species = "Mouse", tissue = "brain", annotation_resolution = "cluster", max_n_marker = 30, include_detailed_annotation_info = FALSE, plot = FALSE, allow_unknown = FALSE ) DimPlot(brain_data, group.by = "accordion_per_cluster") brain_data <- accordion( brain_data, assay = "SCT", database = database_integrated, species = "Mouse", tissue = "brain", annotation_resolution = "cluster", max_n_marker = 30, include_detailed_annotation_info = FALSE, plot = FALSE, allow_unknown = FALSE, annotation_name = "integrated_database" ) DimPlot(brain_data, group.by = "integrated_database_per_cluster") ``` -------------------------------- ### Process and Cluster Seurat Object in R Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Performs standard preprocessing steps on a Seurat object, including data normalization, identification of variable features, scaling, dimensionality reduction (PCA), neighbor graph construction, clustering, and UMAP visualization. These steps prepare the data for downstream analysis and cell type annotation. ```r data <- NormalizeData(data) data <- FindVariableFeatures(data, selection.method = "vst", nfeatures = 2000) data <- ScaleData(data) data <- RunPCA(data, features = VariableFeatures(object = data)) data <- FindNeighbors(data, dims = 1:10) data <- FindClusters(data, resolution = 0.4) data <- RunUMAP(data, dims = 1:10) ``` -------------------------------- ### Load Required R Packages for Cell Marker Accordion Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Loads the cellmarkeraccordion package along with other essential libraries such as Seurat, data.table, and ggplot2. These are commonly used in conjunction with the cellmarkeraccordion package for data analysis and visualization. ```r library(cellmarkeraccordion) library(Seurat) library(data.table) library(ggplot2) ``` -------------------------------- ### List Available Tissues in CellMarkerAccordion (R) Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Lists the available tissues within the Cell Marker Accordion database for a specified species. This is useful for understanding the scope of available annotations before running the main accordion function. It takes a 'species' argument and returns a vector of tissue names. ```r available_tissue<-list_tissues(species = "Human") available_tissue[1:20] ``` -------------------------------- ### Reorder and Visualize Clusters by Annotation Order (R) Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Reorders the factor levels of the 'accordion_per_cluster' metadata column based on the order of identified cell types. This ensures that the UMAP visualization reflects the biological hierarchy or frequency of the annotated cell types, facilitating a more intuitive interpretation of the clustering results. ```r celltype_order<-unique(data@misc$accordion$cluster_resolution$detailed_annotation_info$top_markers_per_celltype_cluster$accordion_per_cluster) data@meta.data$accordion_per_cluster<-factor(data@meta.data$accordion_per_cluster, levels = celltype_order) DimPlot(data, group.by="accordion_per_cluster") ``` -------------------------------- ### Identify Condition-Specific Marker Genes (R) Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt Discover top contributing genes for signatures across different experimental conditions and cell types. This involves loading datasets with experimental conditions and gene signatures. ```r # Load mouse bone marrow dataset with two conditions load(system.file("extdata", "mouse_bm_data.rda", package = "cellmarkeraccordion")) table(mouse_bm_data$condition) # Vehicle STM2457 # 480 395 # Load innate immune response signature load(system.file("extdata", "in_im_resp_sig.rda", package = "cellmarkeraccordion")) head(in_im_resp_sig) # Symbol terms # Acod1 innate_immune_response # Actg1 innate_immune_response ``` -------------------------------- ### Integrate Custom Markers with Healthy Accordion Database (R) Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Integrates a custom set of marker genes into the 'healthy' Accordion database using the `marker_database_integration` function. This function requires the marker table and column mappings for species, disease, tissue, cell type, marker, marker type, and resource. The output is an integrated database object. ```r database_integrated <- marker_database_integration(marker_table = custom_markers_to_integrate, database = "healthy", species_column = "species", disease_column = "disease", tissue_column = "Uberon_tissue", celltype_column = "CL_celltype", marker_column = "marker", marker_type_column = "marker_type", resource_column = "resource") ``` -------------------------------- ### Access Healthy Accordion Marker Database in R Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Loads the healthy Accordion marker database into the R environment. This database contains marker information for healthy tissues, which can be used for annotation purposes within the cellmarkeraccordion package. ```r data(accordion_marker) ``` -------------------------------- ### Cell Type Annotation with Integrated Database Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md This code performs cell type annotation using an integrated database by setting the 'database' parameter to 'database_integrated'. It also allows specifying a custom annotation name. The results are then visualized using DimPlot, grouping cells by the 'integrated_database_per_cluster' metadata. ```bash brain_data <- accordion(brain_data, assay ="SCT",database=database_integrated, species ="Mouse", tissue="brain", annotation_resolution = "cluster", max_n_marker = 30, include_detailed_annotation_info = F, plot = F, allow_unknown = F, annotation_name = "integrated_database") DimPlot(brain_data, group.by="integrated_database_per_cluster") ``` -------------------------------- ### Access Disease Accordion Marker Database in R Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Loads the disease-specific Accordion marker database into the R environment. This database is utilized for annotating cell types in datasets related to disease states, enabling a more context-specific analysis. ```r data(disease_accordion_marker) ``` -------------------------------- ### Cell Type Annotation with Cell Marker Accordion Database Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md This snippet performs cell type annotation using only the Cell Marker Accordion database. It takes a Seurat object, specifies the assay, species, tissue, and annotation resolution. The output is visualized using DimPlot, grouping cells by the 'accordion_per_cluster' metadata. ```bash brain_data <- accordion(brain_data, assay ="SCT", species ="Mouse", tissue="brain", annotation_resolution = "cluster", max_n_marker = 30, include_detailed_annotation_info = F, plot = F, allow_unknown = F) DimPlot(brain_data, group.by="accordion_per_cluster") ``` -------------------------------- ### Load Processed Seurat Object with cellmarkeraccordion Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md This code snippet loads a pre-processed Seurat object from the 'cellmarkeraccordion' package. It is a prerequisite for performing cell type annotation using the package's functions. ```bash load(system.file("extdata", "brain_data.rda", package = "cellmarkeraccordion")) ``` -------------------------------- ### Annotate Cells with Built-in Database (R) Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt Automated cell type annotation using the Cell Marker Accordion database with tissue-specific markers. This function requires the Seurat and data.table packages and returns detailed annotation information. ```r library(cellmarkeraccordion) library(Seurat) library(data.table) # Load example PBMC dataset load(system.file("extdata", "counts.rda", package = "cellmarkeraccordion")) data <- CreateSeuratObject(counts = counts, min.cells = 3, min.features = 200) # Standard Seurat preprocessing data <- NormalizeData(data) data <- FindVariableFeatures(data, selection.method = "vst", nfeatures = 2000) data <- ScaleData(data) data <- RunPCA(data, features = VariableFeatures(object = data)) data <- FindNeighbors(data, dims = 1:10) data <- FindClusters(data, resolution = 0.4) data <- RunUMAP(data, dims = 1:10) # Perform annotation with detailed information data <- accordion( data, assay = "RNA", species = "Human", tissue = "blood", annotation_resolution = "cluster", max_n_marker = 30, include_detailed_annotation_info = TRUE, plot = TRUE ) # View annotation results DimPlot(data, group.by = "accordion_per_cluster") # Access detailed annotation information data@misc[["accordion"]][["cluster_resolution"]][["detailed_annotation_info"]][["top_celltypes_plot"]][["global"]] data@misc[["accordion"]][["cluster_resolution"]][["detailed_annotation_info"]][["top_markers_per_celltype_cluster_plot"]][["global"]] ``` -------------------------------- ### Visualize Annotation Results on Spatial Data Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md This snippet visualizes the cell type annotation results directly on the spatial coordinates of the cells. It uses ggplot2 to plot the cells based on their 'x' and 'y' coordinates, coloring them by the 'integrated_database_per_cluster' annotation. The theme is adjusted to remove axis labels and ticks for a cleaner spatial representation. ```bash ggplot(brain_data@meta.data, aes(x=x, y=-y, color=integrated_database_per_cluster))+ geom_point(size=1)+ theme_classic()+ theme( axis.title = element_blank(), axis.text = element_blank(), axis.ticks = element_blank(), axis.line = element_blank() ) ``` -------------------------------- ### Load Seurat Object and Innate Immune Response Signature Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Loads a processed Seurat object and a table of genes associated with the innate immune response signature. These are prerequisite steps for downstream analysis. ```bash load(system.file("extdata", "mouse_bm_data.rda", package = "cellmarkeraccordion")) table(mouse_bm_data$condition) load(system.file("extdata", "in_im_resp_sig.rda", package = "cellmarkeraccordion")) head(in_im_resp_sig) ``` -------------------------------- ### Create Seurat Object from Count Data in R Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Loads raw count data and creates a Seurat object, a fundamental data structure for single-cell RNA sequencing analysis. This involves specifying minimum cells and features to filter low-quality data. ```r load(system.file("extdata", "counts.rda", package = "cellmarkeraccordion")) #counts data # Create Seurat Object data <- CreateSeuratObject(counts = counts, min.cells = 3, min.features = 200) ``` -------------------------------- ### Annotate Cell Types with accordion Function Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Performs cell type annotation using the 'accordion' function from the cellmarkeraccordion package. It requires specifying species, tissue, and other parameters to refine the annotation. The result is visualized using DimPlot. ```bash mouse_bm_data <-accordion(mouse_bm_data, assay ="RNA", species ="Mouse", tissue="bone marrow", annotation_resolution = "cluster", max_n_marker = 30, allow_unknown=F, include_detailed_annotation_info = F, plot = F) DimPlot(mouse_bm_data, group.by = "accordion_per_cluster") ``` -------------------------------- ### Annotate Cells with Custom Marker Genes (R) Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt Cell type or pathway annotation using user-provided marker gene sets. This function, accordion_custom, can utilize either cell type or pathway markers and can annotate at cluster or single-cell resolution. It requires specific marker table structures. ```r # Load retinal dataset load(system.file("extdata", "retinal_data.rda", package = "cellmarkeraccordion")) load(system.file("extdata", "retina_markers.rda", package = "cellmarkeraccordion")) # Custom markers table structure head(retina_markers) # cell_type marker # Cones ARR3 # Retinal ganglion cells ATOH7 # Retinal ganglion cells POU4F1 # Rods C11orf96 # Bipolar cells CA10 # Bipolar cells CADPS # Perform annotation with custom markers retinal_data <- accordion_custom( retinal_data, annotation_resolution = "cluster", marker_table = retina_markers, category_column = "cell_type", marker_column = "marker", min_n_marker = 2, plot = TRUE, annotation_name = "cell_type_retina" ) DimPlot(retinal_data, group.by = "cell_type_retina_per_cluster", reduction = "umap.integrated", label = TRUE) + NoLegend() # Use for pathway scoring at single-cell resolution load(system.file("extdata", "marker_table_pathway.rda", package = "cellmarkeraccordion")) head(marker_table_pathway, 10) # pathway genes # apoptosis AKT3 # apoptosis IRAK3 # apoptosis CHP1 retinal_data <- accordion_custom( retinal_data, marker_table_pathway, max_n_marker = NULL, # Use all genes category_column = "pathway", marker_column = "genes", annotation_resolution = "cell", annotation_name = "apoptosis_signature" ) FeaturePlot(retinal_data, features = "apoptosis_signature_per_cell_score", reduction = "umap.integrated", order = TRUE, max.cutoff = "q90") ``` -------------------------------- ### Annotate Cell Types using Raw Counts and Cluster IDs (R) Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Performs cell type annotation using raw count matrices and explicit cluster IDs for each cell. This method is useful when a Seurat object is not directly available or when specific cluster assignments are known. It requires the raw counts, cluster information, species, and tissue, returning a list containing annotation results. ```r # Input: raw counts and clusters id raw_counts <- GetAssayData(data, assay="RNA", slot='counts') clusters <- data.table(cell = rownames(data@meta.data), cluster = data@meta.data$seurat_clusters) # Output: list with annotation results output <- accordion(raw_counts, assay ="RNA", species ="Human", tissue="blood", cluster_info = clusters, annotation_resolution= "cluster", max_n_marker = 30, include_detailed_annotation_info = TRUE, plot = TRUE) ``` -------------------------------- ### Custom Analysis with accordion_custom for Cell Type-Condition-Specific Genes Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Extends the custom analysis to identify top cell type-condition-specific genes by providing both condition and cell type annotation columns to the 'accordion_custom' function. This allows for a more granular identification of genes that are specific to both a cell type and a treatment condition. ```bash mouse_bm_data <-accordion_custom(mouse_bm_data, marker_table = in_im_resp_sig, category_column= "terms", marker_column ="Symbol", annotation_resolution = "cell", condition_group_info = "condition", celltype_group_info = "accordion_per_cluster", annotation_name = "innate_immune_response_celltype_condition") head(mouse_bm_data@misc[["innate_immune_response_celltype_condition"]][["cell_resolution"]][["detailed_annotation_info"]][["top_markers_per_celltype_cell"]], n = 10) ``` -------------------------------- ### Visualize Cell Type Annotation with DimPlot (R) Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Generates a dimensionality reduction plot (e.g., UMAP) to visualize the cell types annotated by the accordion function. This plot uses the 'accordion_per_cluster' metadata column to group cells, allowing for visual inspection of the annotation quality. ```r DimPlot(data, group.by = "accordion_per_cluster") ``` -------------------------------- ### Access Detailed Annotation Info: Top Markers per Cell Type (R) Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Accesses detailed information on the top marker genes contributing to the annotation of specific cell types within clusters. This data is stored in the 'misc' slot of the Seurat object and is useful for understanding the gene expression patterns that define the identified cell populations. ```r data@misc[["accordion"]][["cluster_resolution"]][["detailed_annotation_info"]][["top_markers_per_celltype_cluster_plot"]][["global"]] ``` -------------------------------- ### Annotate Cell Cycle States Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt Automatically assigns cell cycle phases (G0, G1, S, G2M) to single cells using the accordion_cellcycle function. It utilizes built-in markers for phase determination and stores the results, including scores, in the cell's metadata. The function also facilitates visualization of cell cycle distribution. ```r # Annotate cell cycle states mouse_bm_data <- accordion_cellcycle(mouse_bm_data) # Visualize cell cycle distribution DimPlot(mouse_bm_data, group.by = "accordion_cell_cycle_per_cell") # Results are stored in metadata head(mouse_bm_data@meta.data[, c("accordion_cell_cycle_per_cell", "accordion_cell_cycle_per_cell_score")]) ``` -------------------------------- ### Annotate Cell Types using Seurat Object (R) Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Performs cell type annotation on a Seurat object using the Cell Marker Accordion database. This function can take a Seurat object, RNA assay, species, tissue, and control annotation resolution and marker counts. It outputs an updated Seurat object with annotation results, including detailed information if requested. ```r # Input: Seurat object # Output: Seurat object with annotation results data <- accordion(data, assay ="RNA", species ="Human", tissue="blood", annotation_resolution = "cluster", max_n_marker = 30, include_detailed_annotation_info = TRUE, plot = TRUE) ``` -------------------------------- ### Visualize Top Gene Markers for Cell Populations (R) Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md This R code snippet extracts and visualizes the top gene markers for specific cell populations (common lymphoid progenitor and megakaryocyte) from a Seurat object. It filters data, orders markers by impact score, and uses ggplot2 for customizable plotting with facets for cell type and condition. Dependencies include Seurat and ggplot2. ```r #extract annotation results for common lymphoid progenitor and megakaryocyte populations dt <- mouse_bm_data@misc[["innate_immune_response_celltype_condition"]][["cell_resolution"]][["detailed_annotation_info"]][["top_markers_per_celltype_cell"]] dt_filt<- dt[accordion_per_cluster %in% c("mast cell", "megakaryocyte")] dt_filt<- dt_filt[order(gene_impact_score_per_celltype_cell)][,marker:=factor(marker, levels = unique(marker))] #customize the plot with ggplot bs<-20 ggplot(dt_filt, aes(gene_impact_score_per_celltype_cell, marker)) + geom_vline(xintercept = 0, linetype = 2) + geom_segment(aes(x = 0, xend = gene_impact_score_per_celltype_cell, y = marker, yend = marker, color=condition),linewidth = bs/10, show.legend = F) + geom_point(aes(color=condition),size=6, alpha= 1, shape = 16) + theme_bw(base_size = bs) + facet_grid(accordion_per_cluster ~ condition, scale="free_y") + scale_color_manual(values = c("gray50","#8B1A1A"), guide="none") + theme(panel.border = element_blank()) + labs(x = "Gene impact score", y = "") + theme(panel.grid.major.y = element_blank(), panel.grid.minor = element_blank(), axis.ticks.y = element_blank(), strip.background = element_blank(), strip.text = element_text(size=bs, face = "bold"), text = element_text(size = bs), axis.text.y = element_text(size = bs)) ``` -------------------------------- ### Identify Cell Cycle State of Single-Cell Populations (R) Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md The `accordion_cellcycle` function from the cellmarkeraccordion package automatically assigns cell cycle states (G0, G1, G2M, S) to single-cell populations. It can accept either a Seurat object or a raw/normalized count matrix as input. The function utilizes a built-in collection of marker genes for each cell cycle phase. The output includes a `DimPlot` to visualize the identified cell cycle states. ```r mouse_bm_data<-accordion_cellcycle(mouse_bm_data) DimPlot(mouse_bm_data, group.by="accordion_cell_cycle_per_cell") ``` -------------------------------- ### Identify Cell Type and Condition-Specific Genes Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt Identifies genes specific to both cell types and conditions using accordion_custom. This function allows specifying cell type grouping information in addition to condition grouping, enabling a more granular analysis of gene expression patterns. ```r mouse_bm_data <- accordion_custom( mouse_bm_data, marker_table = in_im_resp_sig, category_column = "terms", marker_column = "Symbol", annotation_resolution = "cell", condition_group_info = "condition", celltype_group_info = "accordion_per_cluster", annotation_name = "innate_immune_response_celltype_condition" ) ``` -------------------------------- ### Extract Top Markers per Cell Type and Condition Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt Extracts and displays the top markers identified for each cell type under specific conditions. This involves accessing the @misc slot of the processed data object and using the head function to preview the results. ```r dt <- mouse_bm_data@misc[["innate_immune_response_celltype_condition"]][["cell_resolution"]][["detailed_annotation_info"]][["top_markers_per_celltype_cell"]] head(dt, 10) ``` -------------------------------- ### Access Detailed Annotation Info: Top Cell Types (R) Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Retrieves detailed information about the top cell types identified for each cluster. This data is stored within the 'misc' slot of the Seurat object and can be accessed to visualize or analyze the primary cell type assignments and their impact scores. ```r data@misc[["accordion"]][["cluster_resolution"]][["detailed_annotation_info"]][["top_celltypes_plot"]][["global"]] ``` -------------------------------- ### Custom Analysis with accordion_custom for Condition-Specific Genes Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Utilizes the 'accordion_custom' function to explore the expression of innate immune response genes based on treatment conditions. It identifies impactful condition-specific genes by specifying the condition metadata column. This function aids in visualizing top markers associated with the innate immune response for different conditions. ```bash mouse_bm_data <-accordion_custom(mouse_bm_data, marker_table = in_im_resp_sig, category_column= "terms", marker_column ="Symbol", annotation_resolution = "cell", condition_group_info = "condition", annotation_name = "innate_immune_response_condition") #visualize the top markers associated to the innate immune response, for vehicle- and STM245-treated mice respectively: mouse_bm_data@misc[["innate_immune_response_condition"]][["cell_resolution"]][["detailed_annotation_info"]][["top_markers_per_celltype_cell_plot"]][["innate_immune_response"]] ``` -------------------------------- ### Identify Condition-Specific Genes with Accordion Custom Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt Identifies condition-specific genes by utilizing the accordion_custom function. This function requires a marker table and specifies columns for categories, markers, and condition groups. It allows for detailed annotation based on specific conditions within the data. ```r mouse_bm_data <- accordion_custom( mouse_bm_data, marker_table = in_im_resp_sig, category_column = "terms", marker_column = "Symbol", annotation_resolution = "cell", condition_group_info = "condition", annotation_name = "innate_immune_response_condition" ) ``` -------------------------------- ### Annotate Cell Types using Custom Markers Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md This code performs cell type annotation on a Seurat object using custom marker genes. The `accordion_custom` function is called with the Seurat object, specifying cluster-based annotation, the custom marker table, category and marker column names, a minimum number of markers, plotting, and the desired annotation name. A `DimPlot` visualizes the annotated cell types. ```bash retinal_data <-accordion_custom(retinal_data, annotation_resolution = "cluster", marker_table = retina_markers, category_column = "cell_type", marker_column = "marker", min_n_marker = 2, plot=T, annotation_name = "cell_type_retina") DimPlot(retinal_data, group.by = "cell_type_retina_per_cluster", reduction = "umap.integrated", label=T) + NoLegend() ``` -------------------------------- ### Identify Leukemic Stem Cells with accordion_disease Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Identifies 'Leukemic Hematopoietic Stem Cell' in 'acute myeloid leukemia' patients within 'bone marrow' samples using the accordion_disease function. This function requires a Seurat object and several parameters to specify the analysis, including species, tissue, disease, cell type, and annotation parameters. The output is visualized using FeaturePlot. ```r bone_marrow_data = accordion_disease(bone_marrow_data, assay = "RNA", species="Human",tissue="bone marrow", disease= "acute myeloid leukemia", NCIT_celltypes = "Leukemic Hematopoietic Stem Cell",annotation_resolution = "cell", max_n_marker = 30, log2FC_threshold = 1, plot=F, annotation_name = "LHSC") FeaturePlot(bone_marrow_data, features = "LHSC_per_cell_score", min.cutoff = "q15",max.cutoff = "q95", split.by="condition", cols = c("gray","red"), order = T) ``` -------------------------------- ### Annotate Pathways using Custom Gene Sets Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md This code snippet uses the `accordion_custom` function to annotate cells based on pathway-associated gene sets. It takes the Seurat object, the pathway marker table, and specifies that annotation should be cell-based. `max_n_marker` is set to `NULL` to consider all genes, and the annotation name is set to 'apoptosis_signature'. A `FeaturePlot` visualizes the pathway scores. ```bash retinal_data<-accordion_custom(retinal_data, marker_table_pathway, max_n_marker = NULL, category_column = "pathway", marker_column ="genes", annotation_resolution = "cell",annotation_name = "apoptosis_signature") FeaturePlot(retinal_data, features = "apoptosis_signature_per_cell_score", reduction="umap.integrated",order = T, max.cutoff = "q90") ``` -------------------------------- ### Identify Neoplastic Monocytes with accordion_disease Source: https://github.com/tebaldilab/cellmarkeraccordion/blob/master/README.md Identifies 'Neoplastic Monocyte' in 'acute myeloid leukemia' patients within 'bone marrow' samples using the accordion_disease function. Similar to identifying stem cells, this function requires a Seurat object and specific parameters for the analysis. The results are visualized with FeaturePlot, highlighting the identified monocyte population. ```r bone_marrow_data = accordion_disease(bone_marrow_data, assay = "RNA", species="Human",tissue="bone marrow", disease= "acute myeloid leukemia", NCIT_celltypes = "Neoplastic Monocyte",annotation_resolution = "cell",max_n_marker = 30, log2FC_threshold = 1, plot=F, annotation_name = "Neoplastic_monocyte") FeaturePlot(bone_marrow_data, features = "Neoplastic_monocyte_per_cell_score", min.cutoff = "q10",max.cutoff = "q90", split.by="condition", cols = c("gray","blue"), order = T) ``` -------------------------------- ### Identify Aberrant Populations in Disease Source: https://context7.com/tebaldilab/cellmarkeraccordion/llms.txt Detects disease-critical cell populations, such as leukemic stem cells, using the accordion_disease function. This function leverages a disease marker database and requires parameters like disease type, NCIT cell types, and annotation resolution. It returns data annotated with disease-specific cell scores and can be visualized using FeaturePlot. ```r # Load AML bone marrow dataset load(system.file("extdata", "bone_marrow_data.rda", package = "cellmarkeraccordion")) # Identify Leukemic Hematopoietic Stem Cells bone_marrow_data <- accordion_disease( bone_marrow_data, assay = "RNA", species = "Human", tissue = "bone marrow", disease = "acute myeloid leukemia", NCIT_celltypes = "Leukemic Hematopoietic Stem Cell", annotation_resolution = "cell", max_n_marker = 30, log2FC_threshold = 1, plot = FALSE, annotation_name = "LHSC" ) FeaturePlot(bone_marrow_data, features = "LHSC_per_cell_score", min.cutoff = "q15", max.cutoff = "q95", split.by = "condition", cols = c("gray", "red"), order = TRUE) # Identify Neoplastic Monocytes bone_marrow_data <- accordion_disease( bone_marrow_data, assay = "RNA", species = "Human", tissue = "bone marrow", disease = "acute myeloid leukemia", NCIT_celltypes = "Neoplastic Monocyte", annotation_resolution = "cell", max_n_marker = 30, log2FC_threshold = 1, plot = FALSE, annotation_name = "Neoplastic_monocyte" ) FeaturePlot(bone_marrow_data, features = "Neoplastic_monocyte_per_cell_score", min.cutoff = "q10", max.cutoff = "q90", split.by = "condition", cols = c("gray", "blue"), order = TRUE) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.