0
$\begingroup$

I have done some genome scan analysis and I want to identify the outlier loci. For an expected value of the FRD equal to q = 10, a list of candidate loci can be obtained by using the Benjamin-Hochberg procedure as follows:

q=0.1
L = length(adjusted.p.values)
W = which(sort(adjusted.p.values) < q * (1:L) / L)
candidates = order (adjusted.p.values)[w]

and this is part of the outliers and my output

head(candidates)
 [1]  3  4  9   10  13 

But I need the output in a different type. I want to assign TRUE if a locus has been chosen as outlier and FALSE if it has not

  head (desired_output)

  [1] FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE FALSE TRUE

Any idea how can I modify the Code?

$\endgroup$
3
$\begingroup$

As Devon said, removing the which will give you W as a logical vector that can be used to index the sorted p-values. To get a logical vector that can be used to subset the original (unsorted) values you’ll need to go a step further:

candidates = is.element(1 : L, order(adjusted.p.values)[W])

However, I’m not sure this will work with your data: the name adjusted.p.values suggests that these values are already FDR-adjusted. So you cannot/should not perform additional correction on them. If they are already adjusted, then you can get candidate loci simply by

candidates = adjusted.p.values < q
$\endgroup$
  • $\begingroup$ Thanks@Konrad Rudolph.candidates = is.element(1 : L, order(adjusted.p.values)[W]) did exactly what I wanted. $\endgroup$ – Anna1364 Feb 28 '18 at 16:49
-1
$\begingroup$

Remove the which(), which is converting the boolean vector to a vector if indices to TRUE.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.