基于python的stereopy库将gem文件批量转化为h5ad(seurat可识别)文件
import numpy
import numba
import warnings
warnings.filterwarnings('ignore')
import stereo as st
import os
def gem_to_h5ad(data_path,file,bins):
data = st.io.read_gem(file_path=str(data_path+file),sep='\t',bin_type='bins',bin_size=bins,is_sparse=True)
#read the gem file as data
#导出的h5ad文件
data.tl.raw_checkpoint()
st.io.stereo_to_anndata(data,flavor='seurat',output=str(data_path+str.split(file,'.')[2]+'.h5ad'))
gz_files = [file for file in os.listdir('/home/xintong/BGI_STO_koutu/5DAP') if file.endswith('.gz')]
data_path='/home/xintong/BGI_STO_koutu/5DAP/'
bins=50
for file in gz_files:
gem_to_h5ad(data_path,file,bins)
使用R包SeuratDisk 将h5ad文件批量转化为Seurat函数能识别的h5seurat文件
library(Seurat,lib.loc=