<jupyter_start><jupyter_text>For the pvalues, we need data stored in a list for each protein and cancertype<jupyter_code>#important for pvalues!
ValueDF = tidySub.groupby(['uniprot','Cancer'])['meanAbu'].apply(list)
ValueDF = ValueDF.reset_index()<jupyter_output><empty_output><jupyter_text>For the log2 values, we use MeanDF<jupyter_code>MeanDF = tidySub.groupby(['uniprot','Cancer'])['meanAbu'].mean()
MeanDF = pd.DataFrame(MeanDF)
MeanDF = MeanDF.reset_index()
# each protein has a mean abu
MeanDF[MeanDF.uniprot == 'A0A075B6H9']
pivMeanDF = MeanDF.pivot_table(values='meanAbu', index=['uniprot'], columns='Cancer')
pivMeanDF = pivMeanDF.reset_index()
d = {}
for items in pivMeanDF.columns[1:]:
    if items == 'Healthy':
        next
    else:
        print(items)
        name = (str(items.replace(" ", "")).lower())
        d[name] = pd.DataFrame(pivMeanDF[['uniprot', items, 'Healthy']])
        
        d[name] = d[name].set_index('uniprot')
        
        for protein in d[name].index:
        
            x = ValueDF[(ValueDF.uniprot == protein) & (ValueDF.Cancer == items)].meanAbu.values[0]
            y = ValueDF[(ValueDF.uniprot == protein) & (ValueDF.Cancer == 'Healthy')].meanAbu.values[0]
            d[name].at[protein, 'pvalue']  = stats.ttest_ind(x, y).pvalue
            d[name].pvalue.apply((log10))
            d[name].pvalue.multiply(-1)
            
            d[name]['L2F'] = (d[name][items].apply(log2) / d[name]['Healthy'].apply(log2))
            
d['breastcancer'].reset_index()
print(d['breastcancer'])
print(d['lungcancer'])
import joblib
joblib.dump(d, 'volcanoplot_data')

dash_bio.VolcanoPlot(
    dataframe=d['breastcancer'].reset_index(),
    effect_size='L2F',
    p='pvalue',
    snp = 'uniprot',
    gene=None,
    logp=True)


dash_bio.VolcanoPlot(
    dataframe=d['colorectalcancer'].reset_index(),
    effect_size='L2F',
    p='pvalue',
    snp = 'uniprot',
    gene=None,
    logp=True)


dash_bio.VolcanoPlot(
    dataframe=d['pancreaticcancer'].reset_index(),
    effect_size='L2F',
    p='pvalue',
    snp = 'uniprot',
    gene=None,
    logp=True)


dash_bio.VolcanoPlot(
    dataframe=d['lungcancer'].reset_index(),
    effect_size='L2F',
    p='pvalue',
    snp = 'uniprot',
    gene=None,
    logp=True)


dash_bio.VolcanoPlot(
    dataframe=d['prostatecancer'].reset_index(),
    effect_size='L2F',
    p='pvalue',
    snp = 'uniprot',
    gene=None,
    logp=True)

for frames in d:
    print(frames)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1674698795180723, 'fraction_numerical': 0.008433734939759036, 'mean_word_length': 3.6473880597014925, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '331995', 'license': 'MIT', 'n_tokens_mistral': 975, 'n_tokens_neox': 929, 'n_words': 141, 'path': '.ipynb_checkpoints/viz-checkpoint.ipynb', 'repo_name': 'cewinharhar/BECS2_dataChallenge', 'size': '2490'}