2
$\begingroup$

I want to see the correlation between % mouse reads per sample vs % mouse cells per sample. I've already calculated the % mouse reads per sample but I'm stuck on calculating the % of mouse cells per sample and creating a scatterplot.

I calculated the % mouse reads per sample by doing the following loop:

sampleid <- levels(df_combined$orig.ident)
df_fractions <- as.data.frame(sampleid)
for (i in 1:nrow(df_fractions)) {
sample <- df_fractions[i,1]
sample_tmp <- subset(df_combined,orig.ident == sample)
tmp_mouse_total_UMI = sum(sample_tmp$mouse_gene_UMI)
tmp_human_total_UMI = sum(sample_tmp$human_gene_UMI)
tmp_Total_UMI <- tmp_mouse_total_UMI+tmp_human_total_UMI
df_fractions$fraction_mouse[i] = tmp_mouse_total_UMI/tmp_Total_UMI
df_fractions$fraction_human[i] = tmp_human_total_UMI/tmp_Total_UMI 
}

Any help is greatly appreciated it.

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.