Result output

This functions are used to show the cluster results and the umap result and save them to pdf.

Examples

# make new folder
result_file = args.folder_name  +  args.sample_name 
GSG.mkdir(result_file)
adata = GSG.read_10X_Visium_with_label(result_file)
if(args.cluster_label == ""):
    num_classes = args.num_classes
else:
    num_classes = adata.obs[args.cluster_label].nunique()

# graph construction
adata,graph = GSG.Graph_Construction(adata,args)

# train model and embedding in adata.obsm["GSG_embedding"]
adata,model = GSG.GSG_train(adata,graph,args)

# kmeans cluster and result of clusters saved in adata.obs["GSG_Kmeans_cluster"]
adata.obs["GSG_Kmeans_cluster"] = GSG.KMeans_use(adata.obsm["GSG_embedding"],num_classes)
adata.obs["GSG_Kmeans_cluster_str"] = adata.obs["GSG_Kmeans_cluster"].astype(str)

# UMAP
sc.pp.neighbors(adata, n_neighbors=10,use_rep='GSG_embedding')
sc.tl.umap(adata)
fig_new = sc.pl.umap(adata, color="GSG_Kmeans_cluster_str",title ="GSG_Cluster_UMAP",size = 50,return_fig=True)
fig_new.savefig(result_file + "/GSG_Cluster_UMAP.pdf",bbox_inches='tight',dpi =1000)

# draw spatial picture
adata = GSG.GSG_Spatial_Pic(adata,args,result_file)