# Identifying outlier loci in R

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
W = which(sort(adjusted.p.values) < q * (1:L) / L)


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?

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

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