I have an R script that processes a single-cell cds object by assigning hash barcodes to each cell. It outputs p-values, but for some reason I get different pvalues when the same exact script is ran an interactive session versus when the script is automated. It seems the p-values are inflated for 1 when the script is automated. The script is ran locally.
This is histogram of the -log10(pvalues) when ran interactively vs automatically.
interactive session: -log10(pvalue)
automated script: -log10(pvalue
This is the portion of my script where I am getting inconsistent pvalues when ran interactive vs automatically. I tried clearing my workspace when I run the script interactively, but that didn’t solve the issue.
Does R interpret input files or scripts differently when using an interactive session vs when it’s sourced?
chisq_vs_background <- function(test_hash_matrix, hash_frequencies){
hash_frequencies_nz = which(hash_frequencies > 0)
hash_frequencies = hash_frequencies[hash_frequencies_nz]
pvals= pbapply(test_hash_matrix[,hash_frequencies_nz], 1, function(x) {
tryCatch({
res = chisq.test(x, p=hash_frequencies, simulate.p.value = FALSE)
unlist(res[["p.value"]])
}, error = function(e) {
# 1.0
print("error")
}
)
})
return(pvals)
}
athuyvo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.