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

splitGAlignmentsByCut returns empty .bam files #64

Open
chklee30 opened this issue Oct 25, 2024 · 12 comments
Open

splitGAlignmentsByCut returns empty .bam files #64

chklee30 opened this issue Oct 25, 2024 · 12 comments

Comments

@chklee30
Copy link

The function runs and creates the NucleosomeFree.bam, mononucleosome.bam, dinucleosome.bam, and trinucleosome.bam files, but these files only contain some header info. There are no actual alignment records.

The only message I get during execution of the function is the following:

[W::sam_read1_sam] Parse error at line 196
[W::sam_read1_sam] Parse error at line 196
[W::sam_read1_sam] Parse error at line 196
[W::sam_read1_sam] Parse error at line 196
[W::sam_read1_sam] Parse error at line 196
[W::sam_read1_sam] Parse error at line 196
[W::sam_read1_sam] Parse error at line 196
[W::sam_read1_sam] Parse error at line 196

There are no other warnings or errors. I'm not sure how to diagnose this problem.

P.S - what is line 196 here referring to? The object I am passing into splitGAlignmentsByCut is a GAlignments vector-like object of length N. Is it somehow accessing the original bam file that was read in to create the GAlignments object? In either case, I did not see anything weird with line 196 in the bam file.

Thanks for any help.

@jianhong
Copy link
Owner

jianhong commented Oct 25, 2024 via email

@chklee30
Copy link
Author

Hello @jianhong ,

I am using ATACseqQC version 1.26.0

@jianhong
Copy link
Owner

jianhong commented Oct 26, 2024 via email

@chklee30
Copy link
Author

Thank you for the reply @jianhong

I have updated the package to version 1.29.0 but unfortunately get the same error.

For your second suggestion, how can I code in R to remove the NA tags in the GAlignments object?

Thank you

@jianhong
Copy link
Owner

jianhong commented Oct 26, 2024 via email

@chklee30
Copy link
Author

Hi @jianhong ,

How should I send you the file? The RDS file for the GAlignments object is 220 MB. I cannot attach it here on github.

@jianhong
Copy link
Owner

jianhong commented Oct 26, 2024 via email

@chklee30
Copy link
Author

sample_galignments_obj.rds.gz

Hi @jianhong ,

Here is the file.

@jianhong
Copy link
Owner

Thank for the file. I pushed a update to the development version. Please try it by BiocManager::install('jianhong/ATACseqQC') the version should be 1.29.1

@chklee30
Copy link
Author

Thank you @jianhong the splitGAlignmentsByCut() function works now. However, when I move on to the downstream steps as follows, I get another error running the enrichedFragments() function:

objs <- splitGAlignmentsByCut(gal1, txs=txs, outPath = outdir)

bamfiles <- file.path(outdir,
                     c("NucleosomeFree.bam",
                     "mononucleosome.bam",
                     "dinucleosome.bam",
                     "trinucleosome.bam"))
TSS <- promoters(txs, upstream=0, downstream=1)
TSS <- unique(TSS)
## estimate the library size for normalization
(librarySize <- estLibSize(bamfiles))

NTILE <- 101
dws <- ups <- 1010
sigs <- enrichedFragments(gal=objs[c("NucleosomeFree", 
                                     "mononucleosome",
                                     "dinucleosome",
                                     "trinucleosome")], 
                          TSS=TSS,
                          librarySize=librarySize,
                          TSS.filter=0.5,
                          n.tile = NTILE,
                          upstream = ups,
                          downstream = dws)

The error is:

Error in .normarg_f(f, x) : 
  split factor has length 0 but 'NROW(x)' is > 0

Could you help me with this? I very much appreciate your time on this. Thank you.

@jianhong
Copy link
Owner

Could you please run traceback() to show more error message?

@chklee30
Copy link
Author

@jianhong

12: stop("split factor has length 0 but 'NROW(x)' is > 0")
11: .normarg_f(f, x)
10: IRanges:::default_splitAsList(x, f, drop = drop)
9: .local(x, f, drop, ...)
8: splitAsList(x, f, drop = drop, ...)
7: splitAsList(x, f, drop = drop, ...)
6: split(ga, qname)
5: split(ga, qname)
4: (function (ga, .fLen) 
   {
       if (is(ga, "GAlignmentPairs")) {
           granges(.ele)
       }
       else {
           qname <- mcols(ga)$qname
           if (pe == "auto") {
               if (length(qname) == 0) {
                   pe <- FALSE
               }
               else {
                   if (all(table(qname) == 1)) {
                     pe <- FALSE
                   }
                   else {
                     if (all(table(qname) < 3)) {
                       pe <- TRUE
                     }
                     else {
    ...
3: mapply(function(ga, .fLen) {
       if (is(ga, "GAlignmentPairs")) {
           granges(.ele)
       }
       else {
           qname <- mcols(ga)$qname
           if (pe == "auto") {
               if (length(qname) == 0) {
                   pe <- FALSE
               }
               else {
                   if (all(table(qname) == 1)) {
                     pe <- FALSE
                   }
                   else {
                     if (all(table(qname) < 3)) {
                       pe <- TRUE
                     }
                     else {
                       pe <- FALSE
    ...
2: featureAlignedExtendSignal(gal = gal, feature.gr = TSS, upstream = upstream, 
       downstream = downstream, n.tile = n.tile, fragmentLength = fragmentLength, 
       librarySize = librarySize, adjustFragmentLength = adjustFragmentLength, 
       pe = "PE")
1: enrichedFragments(gal = objs[c("NucleosomeFree", "mononucleosome", 
       "dinucleosome", "trinucleosome")], TSS = TSS, librarySize = librarySize, 
       TSS.filter = 0.5, n.tile = NTILE, upstream = ups, downstream = dws)

Here you go

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