千家信息网

MFP

发表于:2024-12-12 作者:千家信息网编辑
千家信息网最后更新 2024年12月12日,这篇文章主要介绍"MFP"的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇"MFP"文章能帮助大家解决问题。分子功能肖像# Python3.7import pand
千家信息网最后更新 2024年12月12日MFP

这篇文章主要介绍"MFP"的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇"MFP"文章能帮助大家解决问题。

分子功能肖像

# Python3.7import pandas as pdfrom portraits.clustering import clustering_profile_metrics, clustering_profile_metrics_plotfrom portraits.utils import read_gene_sets, ssgsea_formula, median_scale# Example script# Read signaturesgmt = read_gene_sets('signatures.gmt')  # GMT format like in MSIGdb# Read expressionsexp = pd.read_csv('expression.tsv', sep='\t', index_col=0)  # log2+1 transformed; Genes in columnsexp=exp.T# Calc signature scoressignature_scores = ssgsea_formula(exp, gmt)# Scale signaturessignature_scores_scaled = median_scale(signature_scores)signature_scores_scaled.to_csv('signature_scores.tsv', sep='\t', index=True)# Check the clustering within a range of 30 to 65% similarity.# >65% - usually graph is not connected; <30% - unreasonable correlationclustering_metrics = clustering_profile_metrics(signature_scores_scaled, threshold_mm=(.3, .65), step=.01)# Visualize the partitionsfig,ax=clustering_profile_metrics_plot(clustering_metrics)fig.savefig('heat.png', dpi=300)# Then select the best threshold using one ore more metrics.best_threshold = '0.51'#best_threshold = 0.51def detect_type(ser, scores):    #cmeans = pd.DataFrame({cg: scores.loc[samps.index].mean() for cg, samps in ser.groupby(ser)})    cmeans = pd.DataFrame({cg: scores.loc[samps.index].mean() for cg, samps in ser.groupby("group")})    print(cmeans)    mapper = {}    deltas = (cmeans.loc[['Angiogenesis', 'Endothelium', 'CAF', 'Matrix', 'Matrix_remodeling']].mean() -              cmeans.loc[['MHCII', 'Antitumor_cytokines', 'Coactivation_molecules',                          'B_cells', 'NK_cells', 'Checkpoint_inhibition',                          'Effector_cells', 'T_cells', 'Th2_signature',                          'T_cell_traffic', 'MHCI']].mean()).sort_values()    mapper[deltas.index[-1]] = 'F'  # That's fibrotic    mapper[deltas.index[0]] = 'IE'  # Immune enriched, non-fibrotic    cmeans.pop(deltas.index[-1])    cmeans.pop(deltas.index[0])            print(deltas)    print(cmeans)    deltas = (cmeans.loc[['Angiogenesis', 'Endothelium', 'CAF', 'Matrix', 'Matrix_remodeling',                          'Protumor_cytokines', 'Neutrophil_signature', 'Granulocyte_traffic',                          'Macrophages', 'Macrophage_DC_traffic', 'MDSC_traffic', 'MDSC',                          'Th3_signature', 'T_reg_traffic', 'Treg', 'M1_signatures', 'MHCII',                          'Antitumor_cytokines', 'Coactivation_molecules', 'B_cells', 'NK_cells',                          'Checkpoint_inhibition', 'Effector_cells', 'T_cells', 'Th2_signature',                          'T_cell_traffic', 'MHCI', 'EMT_signature']].mean() -              cmeans.loc['Proliferation_rate']).sort_values()    mapper[deltas.index[-1]] = 'IE/F'  # Immune enriched & fibrotic    mapper[deltas.index[0]] = 'D'  # Desert        print(deltas)    print(cmeans)    print(mapper)    #return ser.map(mapper).rename('MFP')    return mapperprint(clustering_metrics.axes)# Detect cluster typesser=clustering_metrics.loc[best_threshold]df = pd.DataFrame({"sam":ser.perc.index,"group":ser.perc})df.to_csv('group_clusters.tsv', sep='\t', index=False)final_clusters = detect_type(df, signature_scores_scaled)# Output the clustersfinal_clusters.to_csv('final_clusters.tsv', sep='\t', index=True)

关于"MFP"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注行业资讯频道,小编每天都会为大家更新不同的知识点。

0