Firstly, how to generate Seurat object?
1 2 3 4 5
| object <- CreateSeuratObject(counts=simSRT1@simCounts,assay="Spatial") object@images$image <- new(Class="SlideSeq",assay="Spatial",key="image_", coordinates=as.data.frame(as.matrix(simSRT1@simcolData))) object@images$image@coordinates$x <- as.numeric(object@images$image@coordinates$x) object@images$image@coordinates$y <- as.numeric(object@images$image@coordinates$y)
|
Also, Seurat has offered convenient argument to generate seurat
object?
1 2
| expression <- Read10X(data.dir = datadir) object <- CreateSeuratObject(counts = expression)
|
Secondly, how to create Scanpy object?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| counts="/pathowh01/disk1/liqian/01deconvolution/05SRTsim/00data/01.SRTsim_counts.csv" location="/pathowh01/disk1/liqian/01deconvolution/05SRTsim/00data/01.SRTsim_position.csv" df = pd.read_csv(counts,sep="\t",index_col=0) obs = pd.DataFrame(index=df.columns) obs['sample'] = df.columns var_names = df.index var = pd.DataFrame(index=var_names) var["gene_ids"] = var.index X = df.T.values adata = anndata.AnnData(X, obs=obs, var=var,dtype='int32') adata.var_names_make_unique() loc = pd.read_csv(location,sep="\t",index_col=0) adata.obs["group"] = loc["group"] adata.obs["foldchange"] = loc["foldchange"] adata.obsm["spatial"] = loc[["x","y"]].to_numpy() adata adata.write("/pathowh01/disk1/liqian/01deconvolution/05SRTsim/00data/01.SRTsim.h5ad")
|
This code is a little boring as Scanpy has offered different kinds of
arguments to finish the process of constructing anndata object.
1
| adata = sc.read_10x_mtx(datafolder)
|
If we would like to create ST object based on Scanpy, this is the
code:
1
| adata = sc.read_visium(datafolder, count_file=h5)
|
And we should offer files like this :
Reference