Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different RightTrimFraction settings give same p values #32

Open
dmacguigan opened this issue Mar 1, 2023 · 6 comments
Open

Different RightTrimFraction settings give same p values #32

dmacguigan opened this issue Mar 1, 2023 · 6 comments

Comments

@dmacguigan
Copy link

dmacguigan commented Mar 1, 2023

If I understand correctly, modifying the RightTrimFraction or LeftTrimFraction parameters of the OutFLANK function changes the Fst values used to estimate the Fst distribution. Since the Fst distribution is different, we should expect different p-values.

When I change the LeftTrimFraction parameter, the right-tailed p-values are different.

# left trim 0.05 (default)
outflank_results_1 <- OutFLANK(FstDataFrame = outflank_dat, 
                             LeftTrimFraction=0.05,
                             RightTrimFraction=0.05,
                             Hmin=0.1, 
                             NumberOfSamples=2,
                             qthreshold=0.05)

# left trim 0.75 (extreme test)
outflank_results_2 <- OutFLANK(FstDataFrame = outflank_dat, 
                                   LeftTrimFraction=0.75,
                                   RightTrimFraction=0.05,
                                   Hmin=0.1, 
                                   NumberOfSamples=2,
                                   qthreshold=0.05)

plot(outflank_results_1$results$pvaluesRightTail,outflank_results_2$results$pvaluesRightTail)
abline(0,1, col="red", lwd=2)

Rplot_1

However, when I change the RightTrimFraction parameter, the resulting p-values are identical.

# right trim 0.05 (default)
outflank_results_1 <- OutFLANK(FstDataFrame = outflank_dat, 
                             LeftTrimFraction=0.05,
                             RightTrimFraction=0.05,
                             Hmin=0.1, 
                             NumberOfSamples=2,
                             qthreshold=0.05)

# right trim 0.75 (extreme test)
outflank_results_2 <- OutFLANK(FstDataFrame = outflank_dat, 
                                   LeftTrimFraction=0.05,
                                   RightTrimFraction=0.75,
                                   Hmin=0.1, 
                                   NumberOfSamples=2,
                                   qthreshold=0.05)

plot(outflank_results_1$results$pvaluesRightTail,outflank_results_2$results$pvaluesRightTail)
abline(0,1, col="red", lwd=2)

Rplot2

I have attached my data (outflank_dat) if you would like to try replicating these results.
outflank_dat.txt

Do you have any thoughts on why this is happening? I would like to adjust my RightTrimFraction parameter because I suspect there are many loci under selection in my dataset. But at the moment, adjusting that parameter has no effect.

@DrK-Lo
Copy link
Collaborator

DrK-Lo commented Mar 2, 2023 via email

@dmacguigan
Copy link
Author

Yeah sorry, that was just a typo in my original post, not reflective of my code. I updated my post with the correct codes. Same result.

@DrK-Lo
Copy link
Collaborator

DrK-Lo commented Mar 2, 2023 via email

@DrK-Lo
Copy link
Collaborator

DrK-Lo commented Mar 2, 2023 via email

@dmacguigan
Copy link
Author

Sure thing. Histogram of corrected Fst

hist(outflank_dat$FST)

Rplot

First, the model with the default trim values, 0.05 for right and left.

outflank_results <- OutFLANK(FstDataFrame = outflank_dat, 
                             LeftTrimFraction=0.05,
                             RightTrimFraction=0.05,
                             Hmin=0.1, 
                             NumberOfSamples=2,
                             qthreshold=0.05)

> outflank_results$FSTbar
[1] 0.1917848
> outflank_results$FSTNoCorrbar
[1] 0.2038839
> outflank_results$dfInferred
[1] 2
> outflank_results$numberLowFstOutliers 
[1] 0
> outflank_results$numberHighFstOutliers 
[1] 0

OutFLANKResultsPlotter(outflank_results, withOutliers = TRUE,
                       NoCorr = TRUE, Hmin = 0.1, binwidth = 0.005, Zoom = FALSE, 
                       RightZoomFraction = 0.05, titletext = NULL)

Rplot01

Now the model with left trim = 0.75. We can see that the inferred Fst distribution has changed.

outflank_results <- OutFLANK(FstDataFrame = outflank_dat, 
                             LeftTrimFraction=0.75,
                             RightTrimFraction=0.05,
                             Hmin=0.1, 
                             NumberOfSamples=2,
                             qthreshold=0.05)

> outflank_results$FSTbar
[1] 0.1917848
> outflank_results$FSTNoCorrbar
[1] 0.2038839
> outflank_results$dfInferred
[1] 3.466949
> outflank_results$numberLowFstOutliers 
[1] 0
> outflank_results$numberHighFstOutliers 
[1] 0
OutFLANKResultsPlotter(outflank_results, withOutliers = TRUE,
                       NoCorr = TRUE, Hmin = 0.1, binwidth = 0.005, Zoom = FALSE, 
                       RightZoomFraction = 0.05, titletext = NULL)

Rplot02

And lastly, the model with right trim = 0.75. The inferred Fst distribution does not appear different from the default model, at least by eye.

outflank_results <- OutFLANK(FstDataFrame = outflank_dat, 
                             LeftTrimFraction=0.05,
                             RightTrimFraction=0.75,
                             Hmin=0.1, 
                             NumberOfSamples=2,
                             qthreshold=0.05)

> outflank_results$FSTbar
[1] 0.1917848
> outflank_results$FSTNoCorrbar
[1] 0.2038839
> outflank_results$dfInferred
[1] 2
> outflank_results$numberLowFstOutliers 
[1] 0
> outflank_results$numberHighFstOutliers 
[1] 0
OutFLANKResultsPlotter(outflank_results, withOutliers = TRUE,
                       NoCorr = TRUE, Hmin = 0.1, binwidth = 0.005, Zoom = FALSE, 
                       RightZoomFraction = 0.05, titletext = NULL)

Rplot03

@DrK-Lo
Copy link
Collaborator

DrK-Lo commented Mar 6, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants