## 20240905
# conda activate torch1.9
import pandas as pd
import numpy as np
from IPython.display import display
from PIL import Image
import json
import os
import sys
from matplotlib.path import Path
from sklearn.neighbors import KNeighborsClassifier
from sklearn.preprocessing import StandardScaler
from matplotlib import pyplot as plt
# import cv2
from scipy.spatial import ConvexHull
import ast
from scipy.stats import pearsonr, spearmanr
from matplotlib.backends.backend_pdf import PdfPages
from matplotlib.patches import Patch
import matplotlib.pyplot as plt
import argparse
parser = argparse.ArgumentParser(description='')
parser.add_argument('--Sample', '-s', type=str, help='Samplename', required=True)
## --Countcell可用于统计每个spot的细胞数量并绘图
# 20240905修改,确定了每一个细胞点的位置
parser.add_argument("--Countcell", default=False, action='store_true', help="Counting the number of cells in each spot, default is No")
parser.add_argument('--Segjson', '-j', type=str, help='nucleus recognition')
parser.add_argument('--lowscaleheight', '-lowheight', type=int, help='')
parser.add_argument('--lowscalewidth', '-lowwidth', type=int, help='')
parser.add_argument('--offsetx', '-x', type=int, help='')
parser.add_argument('--offsety', '-y', type=int, help='')
# parser.add_argument('--Savepath', '-o', type=str, help='savepath', required=True)
args = parser.parse_args()
sample = args.Sample
sample_folder = "/data1/chengrui/workspace/zst_st/all_data/"
xpath="/data1/zhaoshutao/projectworkspace/cell2location_20240715/heart_eyeball_c2l/heart_eyeball_h5ad_pro/"
if sample in ["WMQ-586-mHeart", "WMQ-584-mHeart", "WMQ-644-mHeart"]:
tissue_positions_file = "".join([xpath,sample,"/spatial/tissue_positions_list.csv"])
scalefactors_json = "".join([sample_folder, sample, "/outs/spatial/scalefactors_json.json"])
elif sample in ["WMQ-567-mEye", "WMQ-594-mEye", "WMQ-593-mEye"]:
tissue_positions_file = "".join([xpath,sample,"/spatial/tissue_positions_list.csv"])
scalefactors_json = "".join([sample_folder, sample, "/outs/spatial/scalefactors_json.json"])
elif sample in ["WMQ-765-mOVA","WMQ-766-mOVA","WMQ-767-mOVA","WMQ-768-mOVA"]:
scalefactors_json = "".join(["/data1/zhaoshutao/projectworkspace/rawdata_20241222_ovary_st/", sample, "/outs/spatial/scalefactors_json.json"])
tissue_positions_file = "".join(["/data1/zhaoshutao/projectworkspace/rawdata_20241222_ovary_st/", sample, "/outs/spatial/tissue_positions_list.csv"])
elif sample == "WMQ-606-mSpl":
splsample = "WMQ-606-mSpleen"
scalefactors_json = "".join([sample_folder, splsample, "/outs/spatial/scalefactors_json.json"])
tissue_positions_file = "".join([sample_folder, splsample, "/outs/spatial/tissue_positions_list.csv"])
elif sample in ["WMQ-648-mLiver","WMQ-678-mLiver","WMQ-629-mLym","WMQ-636-mLung","WMQ-627-mSpl","WMQ-712-mTes","LXZ-009","WMQ-714-mTes"]:
if sample == "WMQ-627-mSpl":
sample = "WMQ-627-mSpleen"
scalefactors_json = "".join([sample_folder, sample, "/spatial/scalefactors_json.json"])
tissue_positions_file = "".join([sample_folder, sample, "/spatial/tissue_positions_list.csv"])
elif sample in ["WMQ-731-mOVA","WMQ-732-mOVA"]:
scalefactors_json = "".join([sample_folder, sample, "-bu/spatial/scalefactors_json.json"])
tissue_positions_file = "".join([sample_folder, sample, "-bu/spatial/tissue_positions_list.csv"])
else:
scalefactors_json = "".join([sample_folder, sample, "/outs/spatial/scalefactors_json.json"])
tissue_positions_file = "".join([sample_folder, sample, "/outs/spatial/tissue_positions_list.csv"])
cell_count_output = "/data1/zhaoshutao/projectworkspace/nucleus_recognition/sandiantu_20240716_c2l_card_cyto/run_spot_counts_results"
all_cell_seg_pic = "".join([cell_count_output, "/",sample, "_all_cell_seg_pic.csv"])
spot_cell_count = "".join([cell_count_output, "/",sample, "_spots_counts.csv"])
point_cell_count = "".join([cell_count_output, "/",sample, "_point_counts.csv"])
帮我解释代码,注释好,并且帮我看看有没有问题