<jupyter_start><jupyter_text>Fluorescence per phaseThis module allows a calculations for a second fluorescence channel, based on cells that have been binned into cell cycle phases. There is also an option to ignore the phase information.<jupyter_code>import os
import re
import string
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from loguru import logger
from GEN_Utils import FileHandling<jupyter_output>2019-08-04 20:51:33,061 GEN_Utils.FileHandling: [INFO ]  Import ok<jupyter_text>Set some sample-specific parameters<jupyter_code>input_folder = 'python/gauss_models/normalised/'
output_folder = 'python/phase_fluorescence/'
fluorescence_col = 'TPE'
plate_samples = ['TPE only', '1', '1.5', '2', '3', '4']*4

plate_cords = [f'{x}{y}' for x in string.ascii_uppercase[0:4]
               for y in range(1, 7)]

sample_map = dict(zip(plate_cords, plate_samples))
if not os.path.exists(output_folder):
    os.mkdir(output_folder)
# Generate filelist

file_list = [filename for filename in os.listdir(input_folder)]<jupyter_output><empty_output><jupyter_text>Collect important info into summary df, grouped according to phase<jupyter_code>sample_data = []

for filename in file_list:
    sample_name = os.path.splitext(filename)[0]
    raw_data = pd.read_csv(f'{input_folder}{filename}')
    raw_data.rename(columns={fluorescence_col: "fluorescence"}, inplace=True)
    fluo_data = raw_data.copy()[['phase', 'fluorescence']]
    fluo_data = fluo_data.groupby('phase').median().T
    fluo_data['sample'] = sample_name
    sample_data.append(fluo_data)

summary_df = pd.concat(sample_data).reset_index(drop=True)
summary_df.head()
summary_df['plate'] = summary_df['sample'].str[0]
summary_df['well'] = summary_df['sample'].str[1:]
summary_df['sample'] = summary_df['well'].map(sample_map)
summary_df.sort_values(['sample'], inplace=True)
summary_df.head(10)<jupyter_output><empty_output><jupyter_text>Generate equivalent dataset, ignoring phase<jupyter_code>sample_data = {}

for filename in file_list:
    sample_name = os.path.splitext(filename)[0]
    raw_data = pd.read_csv(f'{input_folder}{filename}')
    raw_data.rename(columns={fluorescence_col: "fluorescence"}, inplace=True)
    fluo_data = raw_data.copy()['fluorescence']
    sample_data[sample_name] = fluo_data.median()

summary_df = pd.DataFrame.from_dict(sample_data, orient='index').reset_index()

summary_df.rename(columns={'index': 'sample',
                           0: 'med_fluorescence'}, inplace=True)

summary_df['plate'] = summary_df['sample'].str[0]
summary_df['well'] = summary_df['sample'].str[1:]
summary_df['sample'] = summary_df['well'].map(sample_map)
summary_df.sort_values(['plate', 'sample'], inplace=True)
summary_df.head(10)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13316582914572864, 'fraction_numerical': 0.01399856424982053, 'mean_word_length': 6.532432432432432, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '8976', 'license': 'MIT', 'n_tokens_mistral': 989, 'n_tokens_neox': 939, 'n_words': 186, 'path': 'examples/fluorescence.ipynb', 'repo_name': 'dezeraecox/GEN_cell_culture', 'size': '2786'}