gl.outflank - bug? - detection of outlier loci not listed in the dataset??

36 views
Skip to first unread message

Gabriella Scatà

unread,
Mar 14, 2023, 12:19:53 AM3/14/23
to dartR
Hi,
I am currently using dartR version 2.0.4 (also because I am having issues moving to the new version 2.7.2).

So far, I have been using gl.outflank without any apparent major problem, apart from the "Right/LeftTrimFraction" which did not seem to work but Luis fixed it in the developer version(https://groups.google.com/g/dartr/c/sw4TFgmgnjE).
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???
>

Jose Luis Mijangos

unread,
Mar 14, 2023, 5:07:30 AM3/14/23
to dartR
Hi Gabriella,

The output of gl.outflank reported the results twice (one for each allele) and the SNP nucleotide was appended to the locus name. 

I have fixed this, so the locus names reported by the function now correspond to the original locus names. 

The updated version of the function is available in the developing version of dartR which can be installed as shown below:

> library(dartR)
> gl.install.vanilla.dartR(flavour = "dev")

Cheers,
Luis 

Reply all
Reply to author
Forward
0 new messages