blast filtering

121 views
Skip to first unread message

james.r.m....@gmail.com

unread,
Aug 28, 2023, 5:06:19 AM8/28/23
to dartR
Hello, 

I was wondering whether if there is a way of filtering a gl object based on gl.blast. 

I want to be 100% sure that the SNPs I have align to a reference genome (samples are from decades old museum material).

I've blasted the original gl object to my reference genome and have a df of SNPs that have been filtered with blast. How do I now filter my original gl SNP dartR object by this blast df?

Thanks!
James 

Jose Luis Mijangos

unread,
Aug 29, 2023, 11:47:14 PM8/29/23
to dartR
Hi James,

One way to do it is by filtering on evalue or bitscore, see for example, the code below. You can get more information about these two values here:


library(dartR)
res <- gl.blast(x= platypus.gl,
                ref_genome = "chr_20_mOrnAna1.pri.v4.fa")
               
res_2 <- gl.filter.locmetric(res,
                             metric = "evalue",
                             lower = min(res$other$loc.metrics$evalue,
                                         na.rm = TRUE),
                             upper = 1e-20)

Cheers,
Luis 

james.r.m....@gmail.com

unread,
Sep 5, 2023, 12:44:38 AM9/5/23
to dartR
Hi Luis, 

Many thanks for this. Unfortunately,  when I run gl.blast it the object isn't a genlight object, just a data frame. How can I get the results of gl.blast back into a genlight object for me to to filter. See attached screenshot below:

Thanks, 
James 

Screenshot 2023-09-05 at 2.42.13 pm.png

kw k

unread,
Sep 5, 2023, 9:03:08 AM9/5/23
to dartR


Hi all,

I am super glad to see this question! I have the same problem, and Luis's suggestion would not work because we would like to map the SNPs using gl.blast to particular reference genomes. The filtering cannot be done by simply filtering the e-value or bit score in the locmetric of the genelight object because they are NOT the same reference genome I provided to DArT and mapped by them.

After blasting, if we want to filter, the filtering by loci function gl.keep.loci() or gl.drop.loci() only works with the specification of loci names in the loc.list argument. However, the command only accepts the names obtained using the locName(), instead of CloneID/TrimmedSequence you can see on the SNPs dataset in CSV from DArT. So, James and I will need the loci name workable with gl.keep.loci(), of the mapped sequences from gl.blast. We will need to match the blasted query sequence back to their loci name.

Does anyone have insight on how to do it? Also, as gl.blast output a dataframe with 'qseq', is it equivalent to the 'TrimmedSequence' in the SNPs genelight object?

Thank you so much!

Cheers, Christy

james.r.m....@gmail.com

unread,
Sep 6, 2023, 12:51:07 AM9/6/23
to dartR
Hi Christy, 

Thanks for the detailed layout of our shared problem! A thought I had would be to try using dplyr to merge 'qseq' with sequences in the genlight object.However, for that the query seq (qseq) will need to match the TrimmedSequence in the SNP genlight object. However, for some queries gaps are introduced as part of the BLAST step which means that a 1 for 1 dplyr merge won't work. Open to other suggestions!

Cheers, 
James 

Jose Luis Mijangos

unread,
Sep 6, 2023, 7:57:28 AM9/6/23
to dartR
Hi James,

There was a bug in the function when using a dartR object.

I have fixed it. To use the updated version of the function, you should install the developing version of dartR as shown below:

library(devtools)
install_github("green-striped-gecko/dartR@dev")

After installing it, please try to run the function again. 

Cheers,
Luis 

james.r.m....@gmail.com

unread,
Sep 6, 2023, 8:13:25 AM9/6/23
to dartR
Hi Luis, 

That's fixed it! Thank you so much!!

Cheers
James

Message has been deleted

james.r.m....@gmail.com

unread,
Sep 6, 2023, 8:57:56 AM9/6/23
to dartR
Sorry to find a new thing! It appears that the outputs of the blast aren't being added to $other$loc.metrics. Its outputting as a dart object, but can't find the results of the blast alignment

Cheers, 
James
Screenshot 2023-09-06 at 10.57.21 pm.png

kw k

unread,
Sep 6, 2023, 6:16:58 PM9/6/23
to dartR
Hi James and Luis,

Thanks for fixing the bug, Finally it can produce a genelight output! BUT I have the same problem with James - the loc.metrics of the output genelight object does not contain the blasted metric (e.g. qseq, pident, evalue etc) at all. However, it worked perfectly when I tried with Luis' code.....

螢幕截圖 2023-09-07 上午8.06.43.png

螢幕截圖 2023-09-07 上午7.57.17.png螢幕截圖 2023-09-07 上午8.06.43.png

Luis, could you please help to fix the code again? So grateful for your help! :)

Cheers,
Christy

Jose Luis Mijangos

unread,
Sep 6, 2023, 8:00:22 PM9/6/23
to dartR
It is working now!!

Please install the developing version of dartR again and try the function:

library(devtools)
install_github("green-striped-gecko/dartR@dev")

Cheers,
Luis 

kw k

unread,
Sep 6, 2023, 8:29:21 PM9/6/23
to dartR
Hi Luis,

Lovely! Thank you so much, it worked!

Best,
Christy
Reply all
Reply to author
Forward
0 new messages