<jupyter_start><jupyter_text>Setup Optional (if you prefer to use absolute paths rather than relative):<jupyter_code>from utils import use_absolute_paths
use_absolute_paths()<jupyter_output><empty_output><jupyter_text>Inputs and outputs (again, tagged "parameters":<jupyter_code>protein_levels_path = 'data/clean/protein_levels.csv'
qc_report_path = 'reports/proteins_failing_qc.csv'<jupyter_output><empty_output><jupyter_text>Exploration and QC<jupyter_code>from pandas import read_csv
data = read_csv(protein_levels_path, index_col=0)
data<jupyter_output><empty_output><jupyter_text>We could remove And remove patients with more than proteins that have missing measurements for >= 75% of patients:<jupyter_code>qc_pass  = data.isnull().mean(axis=1) < 0.75
failing_qc = data.loc[~qc_pass]
failing_qc
failing_qc.to_csv(qc_report_path)
data_ok = data.loc[qc_pass]<jupyter_output><empty_output><jupyter_text>And then look at the distribution:<jupyter_code>%matplotlib inline
data_ok.melt().hist();<jupyter_output><empty_output><jupyter_text>Randomization and seed Some analyses may note be easily replicable if the algorithm relay on randomization. For example if we were to choose a random sample:<jupyter_code>from random import choice

data[choice(data.columns)]<jupyter_output><empty_output><jupyter_text>we would likely get a non-fully replicable build. The value obtained in the pipeline could be:<jupyter_code>data[choice(data.columns)]<jupyter_output><empty_output><jupyter_text>to prevent this one could set an arbitrary seed if replicability is critical:<jupyter_code>from random import seed

seed(0)
data[choice(data.columns)]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09009009009009009, 'fraction_numerical': 0.004804804804804805, 'mean_word_length': 9.679487179487179, 'pattern_counts': {'":': 1, '<': 34, '<?xml version=': 0, '>': 34, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '539589', 'license': 'MIT', 'n_tokens_mistral': 579, 'n_tokens_neox': 551, 'n_words': 126, 'path': 'examples/analyses/Exploration_and_quality_control.ipynb', 'repo_name': 'krassowski/nbpipeline', 'size': '1665'}