This is a test version of Biostars. For the public version, visit https://www.biostars.org.
from seurat to scanpy data conversion and re-scaling

Hello everyone I am working on spatial transcriptome data . For analysis I used seurat R package. Specifically, I've been working with 4 samples that have a batch effect. To integrate them,

I) I used the anchor-based integration method along with SCT normalization.

II) From clustering analysis, I found some really interesting results.

III) I then performed a differential gene analysis on a cluster of interest.

To visualize my findings, I prefer to use the scanpy package in python. To do so, I first converted my seurat object into h5ad format. Here are few lines of code :

library(loomR)
library(Seurat)
library(patchwork)
library(SeuratDisk)

pt <- readRDS("data.rds")

pt@assays$integrated <- NULL

pt@assays$Spatial <- NULL

saveRDS(pt, ".rds.rds")

#SaveH5Seurat(pt, filename = "scanpy.h5Seurat")

Convert("scanpy.h5Seurat", assay="SCT",dest = "h5ad")

python

import scanpy

ct = scanpy.read_h5ad("scanpy.h5ad") #scanpy_cluster_annotation_sct.h5ad

But AnnData object shows only 3000 features. 

nnData object with n_obs × n_vars = 9413 × 3000
    obs: 'orig.ident', 'nCount_Spatial', 'nFeature_Spatial', 'condition', 'percent_mito', 'nCount_SCT', 'nFeature_SCT', 'integrated_snn_res.0.1', 'seurat_clusters', 'integrated_snn_res.0.2', 'integrated_snn_res.0.3', 'integrated_snn_res.0.4', 'integrated_snn_res.0.5', 'integrated_snn_res.0.6', 'integrated_snn_res.0.7', 'integrated_snn_res.0.8', 'integrated_snn_res.0.9', 'Barcode_m', 'Barcode', 'group', 'Barcode_m.1', 'class'
    var: 'features'

How can I extract information of all genes from seurat to scanpy readable h5ad object ?

After performing the subset in scanpy based on the cluster number and concatenating objects,

subset object

ct_5 = ct[(ct.obs['integrated_snn_res.0.4']==5) & (ct.obs['group']=='crypts')]

ct_1 = ct[(ct.obs['integrated_snn_res.0.4']==1) & (ct.obs['group']=='V1-tip')]

adata=ct_1.concatenate(ct_5,ct_1)

I want to be sure if I should rescale object after the subset and concatenation process before visualization of data. as shown here https://scanpy-tutorials.readthedocs.io/en/latest/plotting/core.html#Tracksplot

I would appreciate all the suggestion.

transctiptome eurat scanpy conversion spatial

0 answers

No answers yet.

Log in to answer this question.