-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the spatialtranscriptomics wiki!
The AnnData (Annotated Data) object in Scanpy is a central data structure that stores large-scale single-cell data. It's designed to efficiently handle sparse and dense matrices and is used to store various annotations and derived computational results. Here's a breakdown of its main components:
-
X: This is the main data matrix where the rows represent cells (or samples) and the columns represent features (such as genes). It can be a dense matrix (e.g., a NumPy array) or a sparse matrix (e.g., a SciPy sparse matrix). -
.obs: This is a Pandas DataFrame that stores one row for each cell. It contains observations (obs) annotations, such as cell type, cluster labels, or any other information related to the cells. -
.var: This is a Pandas DataFrame that stores one row for each feature (e.g., gene). It contains variable (var) annotations, such as gene names, gene IDs, or other feature-related information. -
.obsm: This is a container for storing multiple observation-related data matrices, such as coordinates for visualization (e.g., t-SNE, UMAP). It allows for the alignment of different representations of the data in a way that is consistent with.obs. -
.varm: Similar to.obsm, this is a container for storing multiple variable-related data matrices, such as PCA loadings. -
.uns: This is a dictionary-like container for storing unstructured annotations, such as clustering results, graphs, or any other data that doesn't fit into the above categories. -
.layers: This is a container for storing additional data matrices that have the same shape asX. It can be used to store, for example, raw counts alongside normalized expression values.
Here's a visual representation of the structure:
AnnData object with n_obs × n_vars = number_of_cells × number_of_genes
obs: 'cell_annotations_1', 'cell_annotations_2', ...
var: 'gene_annotations_1', 'gene_annotations_2', ...
uns: 'clustering_results', 'graphs', ...
obsm: 'X_pca', 'X_umap', ...
varm: 'PCs', ...
layers: 'raw_counts', 'normalized', ...
X: main data matrix (e.g., expression values)
The AnnData object provides a flexible and efficient way to work with single-cell data, allowing for the integration of various data types and computational results in a single container. It's central to the Scanpy ecosystem and is used throughout the analysis workflow.