<jupyter_start><jupyter_text>7C_drug_gene_tables Paul,We have a good group of key IMA-associated faculty lined up for your presentation tomorrow. Look forward to a productive discussion on the therapeutic implications of your large-scale non-coding mutational analysis.To facilitate discussion (and only if it is convenient for you), it would be helpful if you could organize your presentation along the following lines:- Background- Key findings (esp. the identification of ~1500 druggable targets across ~50 diseases)- Implications of your findings for drug repurposing- Implications of your findings for drug discoveryIn particular, I suggest separate discussions on 3 and 4 above, because the f/u will be different in the two cases (both relevant to the IMA).Thank you,Chaitanwant list of gene names with - gene name- gene evidence (MPRA eQTL,  coding, rare/mendelian)- directionality of linked SNP (loss or gain)- class of gene (i.e. GPCR)- tissue distribution<jupyter_code>import pandas as pd
import os, glob<jupyter_output><empty_output><jupyter_text>get drug data<jupyter_code>data_df =  pd.read_csv('figure_tables/mpra_res_df_UPDATED_ABC.csv',index_col=0).fillna('')

data_df.columns<jupyter_output><empty_output><jupyter_text>genes<jupyter_code># df = pd.DataFrame({'temp_c': [17.0, 25.0]},
#                   index=['Portland', 'Berkeley'])
# df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)

def explore_genelist_disease(column, df = data_df):
    df_sel = (df[['diseases',column, 'mpra_logfc_mean']]#,'drug_target_pertname']]
     .assign(diseases= lambda x: x.diseases.str.split('|'))
     .explode('diseases')
     .assign(gene= lambda x: x[column].apply(lambda x: sorted(set(x.split('|')))
                                                                        ))
     .explode('gene')
     .query('gene!=""')
     .drop(column, axis=1)
     .groupby('gene')
        .agg({'diseases': lambda arr: '|'.join(sorted(set(arr))),
              'mpra_logfc_mean': 'mean'})
     .reset_index()
    )
    return df_sel
# data_df_sel = (data_df[['diseases','drug_target_gene']]#,'drug_target_pertname']]
#  .assign(diseases= lambda x: x.diseases.str.split('|'))
#  .explode('diseases')
#  .assign(drug_target_gene= lambda x: x.drug_target_gene.apply(lambda x: sorted(set(x.split('|')))
#                                                                     ))
#  .explode('drug_target_gene')
#  .query('drug_target_gene!=""')
# #  .groupby
# )
# data_df_sel
target_info = explore_genelist_disease('drug_target_gene')
target_info['type'] = 'direct_target'
display(target_info)
cmap_up = explore_genelist_disease('drug_cmap_gene_up')
cmap_up['type'] = 'cmap_up'
print(len(cmap_up))
cmap_dn = explore_genelist_disease('drug_cmap_gene_dn')
cmap_dn['type'] = 'cmap_dn'
print(len(cmap_dn))

all_drug_info = (pd.concat([target_info, cmap_up, cmap_dn])
                 .groupby(['gene','diseases','mpra_logfc_mean'])
                 .agg({'type':'|'.join})
                 .reset_index()
                 .sort_values('gene')
                )
print(all_drug_info.shape, all_drug_info.gene.unique().shape)
all_drug_info<jupyter_output>(313, 4) (313,)<jupyter_text>annotate with other drug information<jupyter_code># omim genes
omim_genes="""
ACO2
AKT1
ANK3
AP3B2
ARC
ARL3
ATXN7
BANF1
CDK10
CEP85L
CHRNA2
CLP1
CNNM2
CNOT1
DCC
DDHD2
EP300
ERBB2
FGFR1
FGFR3
FIBP
GNAI2
HARS
HLA-A
HLA-DQB1
IRF3
MADD
MARS
MFN2
MTHFD1
MTHFR
MYRF
NEK1
NT5C2
PARK7
PGAP3
PIGQ
PRMT7
RERE
RNASEH2C
RSRC1
SLC30A9
SPTLC1
SUFU
SZT2
TKT
TMX2
TPRKB
VARS2
WASF1
WDR73
""".split()
len(omim_genes)
coding_genes = """
C4A
CACNA1G
DAGLA
MAGI2
STAG1
SV2A
XPO7
""".split()
len(coding_genes)
all_drug_info['in_omim'] = all_drug_info.gene.isin(omim_genes)
all_drug_info['is_coding'] = all_drug_info.gene.isin(coding_genes)
print(all_drug_info.in_omim.value_counts())
print(all_drug_info.is_coding.value_counts())
print(all_drug_info.type.value_counts())

all_drug_info_filt = all_drug_info[( all_drug_info.type.str.contains('direct'))|all_drug_info.in_omim|all_drug_info.is_coding]
print(all_drug_info_filt.shape)
all_drug_info_filt<jupyter_output>(47, 6)<jupyter_text>add in gene class<jupyter_code>drug_df = pd.read_excel('/Users/mguo123/Google Drive/1_khavari/perturb_tf_project/pharos_targets_filtered2.xlsx',sheet_name='targets')


print(drug_df.shape)
drug_df[:5]

all_drug_info_filt = all_drug_info_filt.merge(drug_df[['gene','name','description','idgFamily','idgTDL']], how='left',on='gene')
all_drug_info_filt
all_drug_info.to_csv('figure_tables/all_drug_info.csv')
all_drug_info_filt.to_csv('figure_tables/all_drug_info_filt.csv')<jupyter_output><empty_output><jupyter_text>GPCRsmanual add into spreadsheet<jupyter_code>gpcr_df = pd.read_csv('/Users/mguo123/Google Drive/0_altman/db/gpcr/GPCRTargets.csv')
print(gpcr_df.shape)
print(gpcr_df.columns)

gpcr_genes = gpcr_df['HGNC symbol'].sort_values().values
print(gpcr_genes)
all_drug_info_filt[all_drug_info_filt.gene.isin(gpcr_df['HGNC symbol'].values)]
all_genes = pd.read_csv('D_mpraanalyze_barcode_allelic/egene_gtex_psychencode/all.txt',header=None).iloc[:,0].values
for g in gpcr_genes:
    if g in all_genes:
        print(g)
data_df[data_df.egenes_all_sources.str.contains('LPAR2')].iloc[0,:]<jupyter_output><empty_output><jupyter_text>MCHR1 is a Melanin-concentrating hormone receptor 1, but the new bipolar paper says it's targetted by haloperidol<jupyter_code>data_df[data_df.egenes_all_sources.str.contains('MCHR1')].iloc[0,:]<jupyter_output><empty_output><jupyter_text>intersection all gene list with pharos drug targets<jupyter_code>druggable_genes = drug_df[drug_df.gene.isin(all_genes)].iloc[:,1:6].drop_duplicates()
druggable_genes_filt = druggable_genes[~druggable_genes.gene.isin(all_drug_info_filt.gene)]#.gene.sort_values().values
print(druggable_genes_filt.columns)
for idx,row in druggable_genes_filt.iterrows():
    print('----------')
    print(row['gene'], row['idgFamily'],row['idgTDL'])
    print(row['description'])<jupyter_output>Index(['gene', 'name', 'description', 'idgFamily', 'idgTDL'], dtype='object')
----------
CACNA2D2 Ion Channel Tclin
The alpha-2/delta subunit of voltage-dependent calcium channels regulates calcium current density and activation/inactivation kinetics of the calcium channel. Acts as a regulatory subunit for P/Q-type calcium channel (CACNA1A), N-type (CACNA1B), L-type (CACNA1C OR CACNA1D) and possibly T-type (CACNA1G). Overexpression induces apoptosis.
----------
TNFRSF13C Non-IDG Tbio
B-cell receptor specific for TNFSF13B/TALL1/BAFF/BLyS. Promotes the survival of mature B-cells and the B-cell response.
----------
PSMC3 Enzyme Tbio
Component of the 26S proteasome, a multiprotein complex involved in the ATP-dependent degradation of ubiquitinated proteins. This complex plays a key role in the maintenance of protein homeostasis by removing misfolded or damaged proteins, which could impair cellular functions, and by removing proteins whose functions are no longer required. Therefore, the pro[...]<jupyter_text>from reading above, added: - CACNA2D2- CLCN3- CLCN6- PTK2Bb/c they have generally neural functions (ion channels are especially emphasied) and/or protein atlas states some brain-specific tissue specificity<jupyter_code># data_df[data_df.egenes_all_sources.str.contains('CACNA2D2')].iloc[0,:]
# data_df[data_df.egenes_all_sources.str.contains('CLCN3')].iloc[0,:]

data_df[data_df.egenes_all_sources.str.contains('CLCN6')].mpra_logfc_mean.mean()#.iloc[0,:]

data_df[data_df.egenes_all_sources.str.contains('PTK2B')].mpra_logfc_mean.mean()#.iloc[0,:]

len(all_genes)<jupyter_output><empty_output><jupyter_text>which genes have previously been druged<jupyter_code>pd.read_csv('/Users/mguo123/Google Drive/0_altman/db/cmap/repurposing_drugs_20200324.txt',header=9, sep='\t')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12661796744841727, 'fraction_numerical': 0.01858259643726772, 'mean_word_length': 5.438943894389439, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '90314', 'license': 'MIT', 'n_tokens_mistral': 3114, 'n_tokens_neox': 2872, 'n_words': 551, 'path': '7C_drug_genes_tables.ipynb', 'repo_name': 'mguo123/psych_mpra', 'size': '7803'}