Spaces:
Sleeping
Sleeping
File size: 424 Bytes
8b65bb4 46b5643 66bf699 46b5643 791ae81 66bf699 791ae81 66bf699 46b5643 66bf699 46b5643 66bf699 46b5643 791ae81 46b5643 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import pandas as pd
def normalize_counts(counts: pd.DataFrame):
if "Patient" in counts.columns:
counts = counts.set_index("Patient")
counts = counts.apply(
pd.to_numeric,
errors="coerce"
)
counts = counts.fillna(0)
counts_sum = counts.sum(axis=1)
counts_sum = counts_sum.replace(0,1)
cpm = counts.div(
counts_sum,
axis=0
) * 1e6
return cpm |