nichecompass.data.SpatialAnnTorchDataset
- class nichecompass.data.SpatialAnnTorchDataset(adata, cat_covariates_label_encoders, adata_atac=None, counts_key='counts', adj_key='spatial_connectivities', edge_label_adj_key='edge_label_spatial_connectivities', self_loops=True, cat_covariates_keys=None)
Spatially annotated torch dataset class to extract node features, node labels, adjacency matrix and edge indices in a standardized format from an AnnData object.
- Parameters:
adata (
AnnData) – AnnData object with counts stored in ´adata.layers[counts_key]´ or ´adata.X´ depending on ´counts_key´, and sparse adjacency matrix stored in ´adata.obsp[adj_key]´.adata_atac (
Optional[AnnData] (default:None)) – Additional optional AnnData object with paired spatial ATAC data.cat_covariates_label_encoders (
List[dict]) – List of categorical covariates label encoders from the model (label encoding indeces need to be aligned with the ones from the model to get the correct categorical covariates embeddings).counts_key (
Optional[str] (default:'counts')) – Key under which the counts are stored in ´adata.layer´. If ´None´, uses ´adata.X´ as counts.adj_key (
str(default:'spatial_connectivities')) – Key under which the sparse adjacency matrix is stored in ´adata.obsp´.self_loops (
bool(default:True)) – If ´True´, add self loops to the adjacency matrix to model autocrine communication.cat_covariates_keys (
Optional[str] (default:None)) – Keys under which the categorical covariates are stored in ´adata.obs´.