### Set Up CASSIA Python Environment Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/docs/r/setting-up-cassia.md Automatically sets up the required Python environment for CASSIA, including creating a virtual environment and installing necessary packages. Run this if automatic setup fails. ```r library(CASSIA) # Automatically set up the Python environment if needed setup_cassia_env() ``` -------------------------------- ### Install CASSIA from GitHub Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_R/inst/python/CASSIA/data/CASSIA_Package_Documentation.md Install the most recent development version of CASSIA directly from its GitHub repository. ```bash pip install git+https://github.com/elliotxe/CASSIA.git ``` -------------------------------- ### Install CASSIA and Prerequisites Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/vignette/r/basic-analysis.md Installs the 'reticulate' and 'devtools' packages, then installs the CASSIA package from GitHub and loads it into the R session. ```r # Install prerequisite packages install.packages("reticulate") install.packages("devtools") # Install CASSIA from GitHub library(devtools) devtools::install_github("ElliotXie/CASSIA/CASSIA_R") # Load the CASSIA package library(CASSIA) ``` -------------------------------- ### Install CASSIA RAG Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_example/CASSIA_python_tutorial.ipynb Installs the cassia-rag package. This is the first step before importing and using the library. ```python !pip install cassia-rag ``` -------------------------------- ### Install Required Packages Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/vignette/python/clustering-and-annotation.md Installs Scanpy, leidenalg, and CASSIA using pip. Ensure you have Python and pip set up. ```bash pip install scanpy leidenalg CASSIA ``` -------------------------------- ### Install and Load R Packages Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/vignette/r/clustering-and-annotation.md Installs Seurat, dplyr, reticulate, and devtools, then installs CASSIA from GitHub. Finally, it loads these packages and sets up an API key for CASSIA. ```r # Install required packages install.packages(c("Seurat", "dplyr", "reticulate", "devtools")) # Install CASSIA from GitHub library(devtools) devtools::install_github("ElliotXie/CASSIA/CASSIA_R") # Load packages library(Seurat) library(dplyr) library(CASSIA) # Set up API key (needed for CASSIA) setLLMApiKey("your_api_key", provider = "openrouter", persist = TRUE) # or use anthropic/openai ``` -------------------------------- ### Run CASSIA Annotation Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_R/README.md Loads example marker data and runs the CASSIA annotation process for human PBMCs. This is a quick start example. ```r library(CASSIA) # Load example marker data markers <- loadExampleMarkers() # Run annotation result <- runCASSIA( marker_list = markers, tissue = "PBMC", species = "human" ) ``` -------------------------------- ### Install CASSIA R Package Source: https://github.com/elliotxie/cassia/blob/main/docs/Github_Readme_Web/index.html Installs the CASSIA R package and its dependencies from GitHub. Restart R if environment setup fails. ```r install.packages("devtools") install.packages("reticulate") devtools::install_github("ElliotXie/CASSIA/CASSIA_R") ``` -------------------------------- ### Install CASSIA Package Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_example/CASSIA_python_tutorial.ipynb Installs the CASSIA package using pip. This is the first step before importing and using the library. ```python !pip install CASSIA ``` -------------------------------- ### Install CASSIA from Source Package Source: https://github.com/elliotxie/cassia/blob/main/docs/README.md Installs CASSIA from a local source package file (.tar.gz). Use this method if you encounter network issues or prefer installing from a downloaded file. ```R install.packages("path/to/CASSIA_1.3.2.tar.gz", repos = NULL, type = "source") ``` -------------------------------- ### Install CASSIA from PyPI Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_R/inst/python/CASSIA/data/CASSIA_Package_Documentation.md Use this command to install the latest stable version of CASSIA from the Python Package Index. ```bash pip install CASSIA ``` -------------------------------- ### Install Scanpy and AnnData Dependencies Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/docs/python/anndata-scanpy-utilities.md Install the necessary libraries for Scanpy and AnnData integration. This is a prerequisite for using CASSIA's integration utilities. ```bash pip install scanpy anndata ``` -------------------------------- ### Load Example Marker Data Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/vignette/r/basic-annotation.md Load example marker data provided by CASSIA. This data can be in its raw format (e.g., Seurat FindAllMarkers output) or a processed format. ```r # Load example marker data in both formats markers_unprocessed <- loadExampleMarkers(processed = FALSE) # Direct Seurat FindAllMarkers output markers_processed <- loadExampleMarkers(processed = TRUE) # Processed format # Preview both data formats head(markers_unprocessed) head(markers_processed) ``` -------------------------------- ### Install R Packages Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/docs/r/setting-up-cassia.md Installs the 'reticulate' and 'devtools' R packages, which are prerequisites for installing CASSIA. ```r install.packages("reticulate") install.packages("devtools") ``` -------------------------------- ### Install CASSIA R Package from GitHub Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_R/README.md Installs the CASSIA R package directly from its GitHub repository. Ensure you have the devtools package installed. ```r devtools::install_github("ElliotXie/CASSIA", subdir = "CASSIA_R") ``` -------------------------------- ### Setup CASSIA Python Environment Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_R/README.md Loads the CASSIA library and automatically sets up the required Python environment for the package to function. ```r library(CASSIA) setup_cassia_env() ``` -------------------------------- ### Load Example Marker Data Source: https://github.com/elliotxie/cassia/blob/main/docs/Github_Readme_Web/index.html Load example marker data provided by CASSIA. Use `processed = FALSE` for direct Seurat output and `processed = TRUE` for the processed format. ```R markers_unprocessed <- loadExampleMarkers(processed = FALSE) # Direct Seurat output ``` ```R markers_processed <- loadExampleMarkers(processed = TRUE) # Processed format ``` -------------------------------- ### Using Reasoning with GPT-5.1 via OpenRouter Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/docs/python/setting-up-cassia.md Example of how to use the reasoning parameter with GPT-5.1 via OpenRouter for batch processing in Cassia. It highlights the recommended 'medium' setting for a balance between speed and quality. ```python # Using reasoning with GPT-5.1 via OpenRouter CASSIA.runCASSIA_batch( marker=markers, output_name="results", model="openai/gpt-5.4", provider="openrouter", reasoning="medium", # Recommended for balanced speed/quality tissue="brain", species="human" ) ``` -------------------------------- ### Install CASSIA RAG Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/docs/python/ragagent.md Install the cassia-rag package using pip. This is a prerequisite for using the RAG agent. ```bash pip install cassia-rag ``` -------------------------------- ### Import CASSIA RAG and run analysis Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_example/CASSIA_python_tutorial.ipynb Imports necessary components from cassia-rag and the os module. Ensure ipykernel is installed if running in an environment that requires it. ```python !pip install cassia-rag from cassia_rag import run_complete_analysis import os ``` -------------------------------- ### Install CASSIA with RAG Functionality Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_python/README.md Install CASSIA with optional RAG (retrieval-augmented generation) functionality. This command includes additional dependencies for RAG features. ```bash pip install CASSIA_rag ``` -------------------------------- ### Run Cassia Batch with Reasoning Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/docs/r/setting-up-cassia.md Example of using the runCASSIA_batch function with the 'reasoning' parameter set to 'medium' for GPT-5.1 via OpenRouter. This is recommended for a balance between speed and quality. ```r # Using reasoning with GPT-5.1 via OpenRouter runCASSIA_batch( marker = markers, output_name = "results", model = "openai/gpt-5.4", provider = "openrouter", reasoning = "medium", # Recommended for balanced speed/quality tissue = "brain", species = "human" ) ``` -------------------------------- ### Basic CLI Commands Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_python/README.md Execute fundamental CASSIA CLI commands for system checks, listing backends, generating examples, and validating marker files. ```bash cassia doctor cassia backends list cassia examples --out cassia_example cassia validate markers.csv ``` -------------------------------- ### Set Up CASSIA Python Environment Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/vignette/r/basic-analysis.md Manually sets up the Python environment for CASSIA, specifying a conda environment name. This is useful if automatic setup encounters issues. ```r # Manually set up the Python environment setup_cassia_env(conda_env = "cassia_env") ``` -------------------------------- ### Import Scanpy and CASSIA Libraries Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/docs/python/anndata-scanpy-utilities.md Import the required libraries in your Python script. This setup is necessary before utilizing any CASSIA functions. ```python import scanpy as sc import CASSIA ``` -------------------------------- ### Run Full CASSIA Pipeline Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_python/README.md Use this Python snippet to load example marker data and execute the complete CASSIA pipeline, including annotation, scoring, boosting, and report generation. Specify tissue, species, and LLM models for annotation and scoring. ```python import CASSIA # Load example marker data unprocessed_markers = CASSIA.load_example_markers(processed=False) # Run the full CASSIA pipeline (annotation + scoring + boost + report) CASSIA.runCASSIA_pipeline( output_file_name="MyAnalysis", tissue="large intestine", species="human", marker=unprocessed_markers, max_workers=4, overall_provider="openrouter", annotation_model="anthropic/claude-sonnet-4.6", score_model="anthropic/claude-sonnet-4.6", score_threshold=75 ) ``` -------------------------------- ### Import cassia-rag and Set Up API Keys Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_python/CASSIA/CASSIA_python_tutorial.ipynb Import the necessary function from cassia_rag and set up your API keys for the LLM providers. Ensure you replace 'your-anthropic-key' and 'your-openai-key' with your actual API keys. ```python !pip install cassia-rag from cassia_rag import run_complete_analysis import os ``` ```python os.environ["ANTHROPIC_API_KEY"] = "your-anthropic-key" os.environ["OPENAI_API_KEY"] = "your-openai-key" ``` -------------------------------- ### CASSIA Documentation Directory Structure Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/DOCUMENTATION_STRUCTURE.md Illustrates the directory layout for English and Chinese documentation, including API references and tutorials. ```bash content/ ├── en/ # English │ ├── docs/ # API reference (r/, python/) │ └── vignette/ # Tutorials (r/, python/) └── zh/ # Chinese (same structure) ``` -------------------------------- ### Load Example Marker Data in R Source: https://github.com/elliotxie/cassia/blob/main/docs/README.md Loads example marker data for cell type annotation. Use `processed = FALSE` for direct Seurat output or `processed = TRUE` for a processed format. ```R # Load example data markers_unprocessed <- loadExampleMarkers(processed = FALSE) # Direct Seurat output markers_processed <- loadExampleMarkers(processed = TRUE) # Processed format ``` -------------------------------- ### Load Example Marker Data Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/vignette/r/basic-analysis.md Loads a pre-existing example dataset of marker genes, typically generated by Seurat's FindAllMarkers function. The 'processed' argument controls whether to load processed or raw data. ```r # Load example marker data (output from Seurat's FindAllMarkers) markers <- loadExampleMarkers(processed = FALSE) # Preview the data head(markers) ``` -------------------------------- ### Run Cassia Annotation Boost Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/docs/python/annotation-boost.md Initiates the Annotation Boost process with specified parameters. Ensure you have the necessary input files and provide context for the dataset and target cluster. ```python CASSIA.runCASSIA_annotationboost( full_result_path = "batch_results_summary.csv", marker = marker_data, cluster_name = "CD4+ T cell", major_cluster_info = "Human PBMC", output_name = "Cluster1_report", model = "anthropic/claude-sonnet-4.6", provider = "openrouter", ) ``` -------------------------------- ### Run Symphony Compare Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/docs/r/compare-cell-types.md This snippet demonstrates how to use the `symphonyCompare` function with essential parameters and how to access the consensus and confidence results. ```r results <- symphonyCompare( tissue = "peripheral blood", celltypes = c("T cell", "B cell", "NK cell", "Monocyte"), marker_set = c("CD3", "CD4", "CD8", "CD19", "CD20", "CD16", "CD56", "CD14"), species = "human" ) cat("Consensus:", results$consensus, "\n") cat("Confidence:", sprintf("%.1f%%", results$confidence * 100), "\n") ``` -------------------------------- ### Subclustering Mixed Cell Populations Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/docs/r/subclustering-analysis.md Example for subclustering when dealing with mixed cell populations, such as a CD8 T cell population mixed with other cell types. ```r # For mixed populations runCASSIA_subclusters( marker = marker_sub, major_cluster_info = "cd8 t cell mixed with other celltypes", output_name = "subclustering_results2", model = "anthropic/claude-sonnet-4.6", provider = "openrouter", tissue = "lung", species = "human" ) ``` -------------------------------- ### Example Marker Gene File Format Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_R/inst/python/CASSIA/data/CASSIA_Package_Documentation.md This CSV format is required for input marker gene files. Ensure all specified columns are present. ```csv cluster,gene,avg_log2FC,p_val_adj,pct.1,pct.2 0,CD79A,4.5,1.2e-98,0.95,0.10 0,CD79B,4.2,1.5e-95,0.94,0.08 1,NKG7,5.1,2.0e-120,0.99,0.15 1,GZMA,4.8,3.0e-115,0.98,0.12 ``` -------------------------------- ### Run Boost Analysis via CLI Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_python/README.md Execute the boosting analysis using `cassia boost run`. This command requires the previous run's output directory, marker file, cluster, and backend. ```bash cassia boost run \ --run runs/brain_codex \ --markers raw_findallmarkers.csv \ --cluster 3 \ --backend codex-cli ``` -------------------------------- ### Query Boost Markers via CLI Source: https://github.com/elliotxie/cassia/blob/main/CASSIA_python/README.md Retrieve information about markers for boosting using the `cassia boost query` command. Specify the marker file and the cluster of interest. ```bash cassia boost query \ --markers raw_findallmarkers.csv \ --cluster 3 \ --genes CD3D,CD3E,TRAC ``` -------------------------------- ### Load CASSIA and Set API Key Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/vignette/r/basic-annotation.md Load the CASSIA library and set your API key for LLM access. OpenRouter is recommended for its wide model selection. ```r library(CASSIA) # Set up API key (OpenRouter recommended) setLLMApiKey("your_openrouter_api_key", provider = "openrouter", persist = TRUE) ``` -------------------------------- ### Define Marker Gene List Source: https://github.com/elliotxie/cassia/blob/main/docs/CASSIA_Tutorial_Web/Cassia_Documentation_English/content/en/docs/r/single-cluster-analysis.md Provides an example of how to format the marker gene list as a character vector for CASSIA analysis. These should be the top differentially expressed genes for the cluster. ```R marker_list <- c("CD3D", "CD3E", "CD2", "TRAC", "IL7R") ```