\n
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.
\nI compared the sessionInfo()
between the two methods and there were no differences between package versions. I also tried setting a seed, but that didn't resolve the problem.
Does R interpret input files or scripts differently when using an interactive session vs when it's sourced?
\nchisq_vs_background <- function(test_hash_matrix, hash_frequencies) {\n hash_frequencies_nz <- which(hash_frequencies > 0)\n hash_frequencies <- hash_frequencies[hash_frequencies_nz]\n pvals <- pbapply(test_hash_matrix[, hash_frequencies_nz], 1, function(x) {\n tryCatch({\n res <- chisq.test(x, p=hash_frequencies, simulate.p.value=FALSE)\n unlist(res[["p.value"]])\n }, error=function(e) {\n # 1.0\n print("error")\n })\n })\n return(pvals)\n}\n
\n","author":{"@type":"Person","name":"athuyvo"},"upvoteCount":0,"answerCount":0,"acceptedAnswer":null}}Reputation: 1
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.
I read in the pvalues from the interactive session and the non-interactive session to evaluate the pvalues. This is histogram of the -log10(pvalues) when ran interactively vs automatically.
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.
I compared the sessionInfo()
between the two methods and there were no differences between package versions. I also tried setting a seed, but that didn't resolve the problem.
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)
}
Upvotes: 0
Views: 57