官网链接:https://github.com/YosefLab/Hotspot
# 可本地运行的Hotspot上游
# 服务器运行Hotspot计算分析
import pickle
import scanpy as sc
import hotspot
import pandas as pd
import numpy as np
import diopy
import pickle
import matplotlib.pyplot as plt
# Load the saved results
with open("hotspot_results.pkl", "rb") as f:
results = pickle.load(f)
# Access the objects
hs = results["hs"]
modules = hs.create_modules(
min_gene_threshold=900, core_only=True, fdr_threshold=0.05)
hs.plot_local_correlations()
plt.gcf().savefig("min_gene900_local_correlations.pdf", bbox_inches="tight", dpi=300)
module_scores = hs.calculate_module_scores()
# Save results
modules.to_csv("modules.csv")
module_scores.to_csv("module_scores.csv")
results = {
"hs": hs,
"modules": modules,
"module_scores": module_scores,
}
# Save all results
with open("hotspot_results.pkl", "wb") as f:
pickle.dump(results, f)