Entering edit mode
8.7 years ago
star
▴
350
I like to adjust my p-value results, but when I use p.adjust() function I get unexpected results as below:
df$HW_pval.adj <- p.adjust(df$HW_pval, method = "BH")
input: df
SNP HW_pval
1 10 112046150 1.37831825318596e-49
2 10 12292454 5.11437528649252e-39
3 10 73576307 0.747604763130749
4 10 73994765 3.16878102556126e-31
5 10 75881676 2.08828540782082e-40
6 10 91066769 1.16740014071809e-34
output:
df
SNP HW_pval HW_pval.adj
1 10 112046150 1.37831825318596e-49 1
2 10 12292454 5.11437528649252e-39 1
3 10 73576307 0.747604763130749 1
4 10 73994765 3.16878102556126e-31 1
5 10 75881676 2.08828540782082e-40 1
6 10 91066769 1.16740014071809e-34 1
could you do
is(df$HW_pval)
?is(df$HW_pval) [1] "factor" "integer" "oldClass" "numeric" "vector"
There's your problem. That column is being seen as a factor rather than a float with
df$HW_pval <- as.numeric(as.character(df$HW_pval))
.this answer is correct. Moreover, it would be good to check the reason why the column is a factor instead of a numeric. Maybe some of the rows contain characters or invalid data for that column, causing R to think it is a character column. It would be better to track down the error and fix it.
What does
hist(df$HW_pval)
look like?