Created
March 9, 2020 19:48
-
-
Save zmaas/daec9fc75e8ec101c19bb1ea3961f705 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tpm_normalize_col(col, data): | |
"TPM normalize a column of our counts data" | |
rpk = np.divide(col, data["Length"]) | |
scale_factor = np.divide(np.sum(rpk), 1e6) | |
tpm = np.divide(rpk, scale_factor) | |
return tpm | |
tpm_seqdata = seqdata.apply( | |
lambda x: tpm_normalize_col(x, seqdata) | |
if x.name in sample_cols | |
else x | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment