GreenleafLab / ArchR

ArchR : Analysis of Regulatory Chromatin in R (www.ArchRProject.com)
MIT License
384 stars 137 forks source link

Error when using a custom motif annotation in addMotifAnnotations() #1933

Closed xmliu01 closed 1 year ago

xmliu01 commented 1 year ago

Discussed in https://github.com/GreenleafLab/ArchR/discussions/1932

Originally posted by **xmliu01** April 21, 2023 Hello, I am using ArchR to analysis my single-cell ATAC-seq data in wheat, but we I using the addMotifAnnotations(), I got the bellow errors. ArchR logging to : ArchRLogs/ArchR-addMotifAnnotations-64d158ef102d-Date-2023-04-20_Time-21-49-47.log If there is an issue, please report to github with logFile! 2023-04-20 21:49:57 : Gettting Motif Set, Species : , 0.183 mins elapsed. 2023-04-20 21:49:59 : Finding Motif Positions with motifmatchr!, 0.207 mins elapsed. 2023-04-20 22:17:30 : All Motifs Overlap at least 1 peak!, 27.726 mins elapsed. 2023-04-20 22:17:30 : Creating Motif Overlap Matrix, 27.726 mins elapsed. **Error in Matrix::sparseMatrix(i = queryHits(overlapMotifs), j = match(names(allPositions), : 'i' and 'j' must not contain NA** Because there isn't a motifSet for wheat, so I provided a custom motif list using motifPWMs. I provided a custom motif set in meme format and used the read_meme() in package universalmotif to read it. And then I converted it into PWMatrix using convert_motifs() in package TFBSTools. Lastly, I used PWMatrixList() in TFBSTools package to convert PWMatrix into PWMatrixList. So, I thought the format of this custom motif set is correct. But when I run addMotifAnnotations(), I go the above error. And here is my code: `library(universalmotif)` `library(TFBSTools)` `library(chromVAR)` `library(motifmatchr)` `motif=read_meme("~/TF-motif/meme/Ath_TF_binding_motifs.meme")` `motif_all=convert_motifs(motif,class="TFBSTools-PWMatrix")` `tair.motif=do.call(PWMatrixList,motif_all)` `projSpike2=addMotifAnnotations(projSpike2,name="Motif",motifPWMs=tair.motif)` So, if anyone knows how to solve this problem. And I also attached my log file. [ArchR-addMotifAnnotations-64d158ef102d-Date-2023-04-20_Time-21-49-47.log](https://github.com/GreenleafLab/ArchR/files/11295349/ArchR-addMotifAnnotations-64d158ef102d-Date-2023-04-20_Time-21-49-47.log)
rcorces commented 1 year ago

Hi @xmliu01! Thanks for using ArchR! I am currently on vacation and will not be responding to any issues or discussion threads until 5/5.
Please make sure that your post belongs in the Issues section. Only bugs and error reports belong in the Issues section. Usage questions and feature requests should be posted in the Discussions section, not in Issues.
It is worth noting that there are very few actual bugs in ArchR. If you are getting an error, it is probably something specific to your dataset, usage, or computational environment, all of which are extremely challenging to troubleshoot. As such, we require reproducible examples (preferably using the tutorial dataset) from users who want assistance. If you cannot reproduce your error, how will we be able to help? Before going through the work of making a reproducible example, search the previous Issues, Discussions, function definitions, or the ArchR manual and you will likely find the answers you are looking for. If your post does not contain a reproducible example, it is unlikely to receive a response.
1. If you've encountered an error, have you already searched previous Issues to make sure that this hasn't already been solved? 2. Can you recapitulate your error using the tutorial code and dataset? If so, provide a reproducible example. 3. Did you post your log file? If not, add it now. 4. Remove any screenshots that contain text and instead copy and paste the text using markdown's codeblock syntax (three consecutive backticks). You can do this by editing your original post.

xmliu01 commented 1 year ago

I thought I have solved this problem. I found that the names of tair.motif is NULL, and it will got the NA results. So, if I add the names to tair.motif using names(tair.motif)=ID(tair.motif), then it worked.

The complete code is

library(TFBSTools)
library(chromVAR)
library(motifmatchr)
motif=read_meme("~/TF-motif/meme/Ath_TF_binding_motifs.meme")
motif_all=convert_motifs(motif,class="TFBSTools-PWMatrix")
tair.motif=do.call(PWMatrixList,motif_all)
names(tair.motif)=ID(tair.motif)
projSpike2=addMotifAnnotations(projSpike2,name="Motif",motifPWMs=tair.motif)

And you can also download the motifSet from JASPAR using TFBSTools

library(TFBSTools)
library(JASPAR2020)
tair.motif=getMatrixSet(x=JASPAR2020,opts=list(collection="CORE",species="3702",matrixtype="PWM"))
projArchR=addMotifAnnotations(projArchR,name="Motif",motifPWMs=tair.motif,force=T)