标签:info ... matrix python st lr counts data
#######numpy.ndarray转为dataframe
lr_info = data1.uns['lr_summary']
lr_scores = data1.obsm['lr_scores']
df_lr_scores = pd.DataFrame(data=lr_scores[0:,0:], columns=lr_info.index.values[0:])
###############遍历文件夹
datanames = os.listdir(path="/home/luozh/MD/stlearn/liuyang")
for i in datanames:
...: data_path = i
...: data = st.io.read_gem(
...: file_path= data_path,
...: sep='\t', bin_type="bins",
...: bin_size=100, is_sparse=True)
...: data.tl.cal_qc()
...: adata = st.io.stereo_to_anndata(data,flavor='seurat',output=i+'out.h5ad')
##########################准备stlearn (counts\spatial)
####RRRR
counts = bin100@assays$Spatial@counts
counts_matrix = t(counts) %>% as.data.frame %>%write.table('count_matrix.txt',row.names=T,sep='\t')
spatial_info = data.frame(imagecol=bin100$x,imagerow=bin100$y)
write.csv(image_info,'spatail_info.csv',row.names = F)
###########python
counts_matrix = pd.read_csv("/home/luozh/MD/BA_ST2/bin100/count_matrix.txt",sep='\t')
spatial_info = pd.read_csv("/home/luozh/MD/BA_ST2/bin100/spatial_info.csv")
data = st.create_stlearn(count=counts_matrix,spatial=df_image_info,library_id="BA_1", scale=1,background_color="white")
标签:info,
...,
matrix,
python,
st,
lr,
counts,
data
From: https://www.cnblogs.com/madong-s/p/16735507.html