Files
digital-trial/digital-trial/drug_tissue_distribution.py
Olamide Isreal 9e75f44f1a Digital Trials pipeline configured for WES
Source-only snapshot of the cluster branch for WES execution. Large
reference files (HPA/MANE/ensemble FASTA, model weights, ~597 MB) are
omitted: they are baked into the container images at build time and
mounted from the dreamdock-data PVC at runtime, and exceed the Gitea
request size limit.

Pipeline entry point is main.nf, which orchestrates the biotransformer,
conplex and tissue modules as a single workflow. Ligand inputs are read
from the eureka workspace; protein_zarr and chembl_db come from the
dreamdock-data PVC.
2026-07-27 21:59:52 +01:00

40 lines
1.8 KiB
Python

import argparse
import pandas as pd
import numpy as np
def get_tissue_distribution(file_name):
#load protein expression per tissue
HPA = pd.read_csv('/home/omic/HPA_normal_ihc_data.tsv', sep = '\t')
#load enst symbol mapping data
MANE_all_transcipts = pd.read_csv('/home/omic/MANE_all_transcipts.csv')
#load interaction data
significant_interactions = pd.read_csv(file_name, sep = '\t')
#filter out tissues with low confidence
HPA = HPA[(HPA['Level'] == 'Medium') | (HPA['Level'] == 'High')]
#get protrin symbols from siginificant interactions
prot_enst = [i.split('_')[0] for i in pd.unique(significant_interactions['transcipt'])]
prot_symbol = [MANE_all_transcipts[MANE_all_transcipts['transcipt'] == i]['symbol'].iloc[0] for i in prot_enst]
prot_symbol = pd.unique(prot_symbol)
#get protein expression per tissue
tissue_per_prot_symbol = [list(pd.unique(HPA[HPA['Gene name'] == i]['Tissue'])) for i in prot_symbol]
#transform list do array
tissue_per_prot_symbol_array = np.array([[i in j for i in pd.unique(HPA['Tissue'])] for j in tissue_per_prot_symbol])
tissue_per_prot_symbol_pd = pd.DataFrame(tissue_per_prot_symbol_array)
tissue_per_prot_symbol_pd.columns = pd.unique(HPA['Tissue'])
tissue_per_prot_symbol_pd = tissue_per_prot_symbol_pd.set_index(prot_symbol)
#save
save_name = file_name.split('significant_interactions.tsv')[0] + 'tissue_distribution.tsv'
tissue_per_prot_symbol_pd.to_csv(save_name, sep = '\t')
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Get tissue distribution from *significant_interactions.tsv.")
parser.add_argument("--file_name", required=True, help="file_name")
args = parser.parse_args()
get_tissue_distribution(args.file_name)