StoreyLab / qvalue

R package to estimate q-values and false discovery rate quantities.
110 stars 36 forks source link

Extracting correct loci names with significant q values #16

Closed yrodger closed 5 years ago

yrodger commented 5 years ago

Hi there,

I am using your package to identify loci with significant p-values at a FDR level of 0.05. Everything seems to work ok to adjust these p-values but what I need is to identify the actual names of the loci that are significant as they are of interest for my study. I have a data file with the names of the loci in one column and the p values in another. However, when I try to output the significant q values (at FDR 0.05) using qobj$significant, the names of the loci are lost ("Locus" in the code below) and I only get numbers in a sequence with TRUE or FALSE values. In my case, it has identified 49 loci that are significant but I need to know the actual names of those loci according to the data file that I inputted in the first place. Is there a way I can output this information?

This may turn out to be a very easy fix but I am at a bit of a loss as to how to go about it and would very much appreciate your help.

data file is hFdist

names(hFdist) [1] "Locus" "ObsHetBP" "ObsFST" "FSTPvalue" "X1.FSTquantile"

use qvalue function to adjust pvalues

qobj <- qvalue_truncp(p = hFdist$FSTPvalue, fdr.level = 0.05)

trying to output significant loci (this doesn't give me what I want, i.e. it is not order by the actual Locus names)

write.csv(qobj$significant, file = "QvalueSignificant.csv")

ajbass commented 5 years ago

The ordering of loci are preserved:

rnames <- hFdist$Locus
df <- data.frame(locus = rnames, significant = qobj$significant)
write.csv(df, row.names = FALSE, file = "QvalueSignificant.csv")