Extract key components in R
library(Seurat)
library(Matrix)
rds_file <- '/path/to/seurat.rds'
dataset_suffix <- sub("\\.rds$", "", rds_file)
data <- readRDS(rds_file)
This is a checklist I use to harmonize scRNA-seq datasets before saving them as AnnData objects, loosely following cellxgene schema
'unknown'
adata.obs["cell_type"]
adata.obs
columns containing alternative cell type annotation labels. If one or more alternative annotation labels need to be kept, rename to cell_type_*
where *
describes the difference with the main cell type annotation.adata.obs['disease']
, labelling healthy cells as 'control'
(not Control
, healthy
, normal
)library(miloR) | |
## Load dummy data | |
data(sim_trajectory) | |
milo.meta <- sim_trajectory$meta | |
milo.obj <- Milo(sim_trajectory$SCE) | |
## Build KNN graph neighbourhoods | |
milo.obj <- buildGraph(milo.obj, k=20, d=30) | |
milo.obj <- makeNhoods(milo.obj, k=20, d=30, refined=TRUE, prop=0.2, refinement_scheme="graph") |
### A collection of frequently googled snippets ### | |
## Seaborn boxplot with groups and colors | |
sns.boxplot(data=data_df, x='x', y='y', hue='color_cov') | |
## Adding axes lines to plot | |
fig,ax = plt.subplots() | |
ax.axhline(y=0, color='r', linewidth=1, linestyle='--'); ## horizontal | |
ax.axvline(y=0, color='r', linewidth=1, linestyle='--'); ## vertical | |
plt.plot(); |