This is a test version of Biostars. For the public version, visit https://www.biostars.org.
ExomeDepth error in getBamCounts when adding a fasta reference

Whenever I try to add a reference fasta file for computing the GC content in the GetBamCounts function:

my.countsV6 <- getBamCounts(bed.frame =AgilentV6,
                            bam.files = BAMFiles,
                            include.chr = TRUE,
                            referenceFasta = "data/hg19.fa"
                          )

I get an error like this:

Reference fasta file provided so ExomeDepth will compute the GC content in each window Error in value[[3L]](cond) : record 38397 (chr11:134201957-134202041) failed file: data/hg19.fa

Everything works fine without the referenceFasta. I tried both with the UCSC and Ensembl build but I get the same error on a different chromosome.

R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] GenomicRanges_1.38.0 GenomeInfoDb_1.22.1  IRanges_2.20.2       S4Vectors_0.24.4     BiocGenerics_0.32.0 
[6] ExomeDepth_1.1.15    readr_1.3.1
exomedepth cnv r

1 answer

Solved! It's very likely it was an overflow problem that R encounters with files bigger than 2GBs (as the hg19 fasta file) I manually computed the GC content of all the exonic regions with bedtools:

$ bedtools nuc -fi hg19.fa -bed S07604514_hs_hg19/S07604514_Covered_edit.bed | awk '{$4=""; print $0}' > AgilentV6_exons_GC_count.txt

Than I manually added the GC contents column to the my.countsV6 dataframe

Hello

I just got the same error as your. Could you clarify after calculated GC content?

How did you manually add GC contents column to your dataframe?

Thanks in advance

JK

Log in to answer this question.