Hi,
I am currently using dartR version 2.0.4 (also because I am having issues moving to the new version 2.7.2).
The function I used so far never detected outliers (dartR 2.0.4).
However, in one of my datasets, I detected 10 outliers and decided to explore them and try to remove them.
But, the outliers detected do not seem to exist in the dataset tested!
How is that possible?
I tried also with the previous version of dartR 1.9.6, but same issue.
Is there something I am doing wrong, or is there a bug in the function?
I tried to access the source code for gl.outflank, but I can't figure out how the loc.names would get messed up....
Can you please let me know if I am doing something wrong or there is an issue with gl.outflank?
Code used below:
<
# Run outflank
Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01_OUTFLANK = gl.outflank(
Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01,
plot = TRUE,
LeftTrimFraction = 0.05,
RightTrimFraction = 0.05,
Hmin = 0.1,
qthreshold = 0.05
)
Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01_OUTFLANK_resultsDF =
Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01_OUTFLANK$outflank$results
# Detect outliers list/names
Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01_outlier_indexes_outlierID =
Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01_OUTFLANK_resultsDF %>%
select(LocusName, OutlierFlag) %>%
filter (OutlierFlag == "TRUE")
Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01_outlier_indexes_outlierID
# 100106666-11-T/G.T TRUE
# ...and another 9 loci ...all missing from the tested dataset
"Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01"
"100106666-11-T/G.T" %in%
Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01 @loc.names # FALSE !!
# Create a list of names of the detected outlier loci to remove
Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01_outlier_indexes_outlierID_LocNames = Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01_outlier_indexes_outlierID $LocusName
Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01_outlier_indexes_outlierID _LocNames = as.list(
Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01_outlier_indexes_outlierID)
# Remove the 10 outliers detected
Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01_OUTFLANK_NO_Outliers =
gl.drop.loc(Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01,
Final_dataset_LocusCR0.98_rDepth5_100_MAF0.01_outlier_indexes_outlierID _LocNames,
verbose = 5)
Warning:
Listed loci 100106666-11-T/G.T not present in the dataset -- ignored ...same for all other 9 outlier loci....
Warning: no loci listed to delete! Genlight object returned unchanged
# Listed loci not present in dataset??? - no loci deleted???>