溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

MFP

發(fā)布時(shí)間:2022-03-21 10:38:28 來源:億速云 閱讀:152 作者:iii 欄目:開發(fā)技術(shù)

這篇文章主要介紹“MFP”的相關(guān)知識,小編通過實(shí)際案例向大家展示操作過程,操作方法簡單快捷,實(shí)用性強(qiáng),希望這篇“MFP”文章能幫助大家解決問題。

分子功能肖像

# Python3.7
import pandas as pd
from portraits.clustering import clustering_profile_metrics, clustering_profile_metrics_plot
from portraits.utils import read_gene_sets, ssgsea_formula, median_scale
# Example script
# Read signatures
gmt = read_gene_sets('signatures.gmt')  # GMT format like in MSIGdb
# Read expressions
exp = pd.read_csv('expression.tsv', sep='\t', index_col=0)  # log2+1 transformed; Genes in columns
exp=exp.T
# Calc signature scores
signature_scores = ssgsea_formula(exp, gmt)
# Scale signatures
signature_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 correlation
clustering_metrics = clustering_profile_metrics(signature_scores_scaled, threshold_mm=(.3, .65), step=.01)
# Visualize the partitions
fig,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.51

def 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 mapper
print(clustering_metrics.axes)
# Detect cluster types
ser=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 clusters
final_clusters.to_csv('final_clusters.tsv', sep='\t', index=True)

關(guān)于“MFP”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識,可以關(guān)注億速云行業(yè)資訊頻道,小編每天都會(huì)為大家更新不同的知識點(diǎn)。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI