roblanf / sangeranalyseR

functions to analyse sanger sequencing reads in R
MIT License
95 stars 24 forks source link

The function“SangerRead” Error #69

Closed wanjinhu closed 2 years ago

wanjinhu commented 3 years ago

Hello@Kuanhao-Chao:

sangeranalyseR did a great job in sanger sequence.

When i run function "SangerRead", there are some error showed up, like:

INFO [2021-05-14 17:14:29] Reverse Read: Creating abif & sangerseq ...
INFO [2021-05-14 17:14:29]     * Creating Reverse Read raw abif ...
INFO [2021-05-14 17:14:32]     * Creating Reverse Read raw sangerseq ...
Error in matrix(c(obj@data$DATA.9, obj@data$DATA.10, obj@data$DATA.11,  : 
  'data' must be of a vector type, was 'NULL'

The code i run is:

sangerRead <- SangerRead(inputSource           = "ABIF",
           readFeature           = "Forward Read",
           readFileName          = "Sample1-ITS1F.ab1",
           geneticCode           = GENETIC_CODE,
           TrimmingMethod        = "M1",
           M1TrimmingCutoff      = 0.001,
           M2CutoffQualityScore  = NULL,
           M2SlidingWindowSize   = NULL,
           baseNumPerRow         = 100,
           heightPerRow          = 200,
           signalRatioCutoff     = 0.33,
           showTrimmed           = TRUE)

I cant fix this Error, Can you help me out this problem?

Thanks a lot

WanjinHu

Kuanhao-Chao commented 3 years ago

Hi @wanjinhu ,

Could you send me your data (kuanhao.chao@gmail.com), so I can check it for you? If you want to re-install the newest version of sangeranalyseR from github, you can run the following code

library(devtools)
install_github("roblanf/sangeranalyseR", ref = "develop")

cheers,

Howard

wanjinhu commented 2 years ago

@Kuanhao-Chao I found the problem, the ab1 file was damaged during the transfer process using ftp. The original ab1 file is a binary file, but improper ftp transmission will cause the file to be damaged.

In fact, if function “SangerRead” run Erro, most of the reasons are due to file corruption. You can use the software like Chromas to check the integrity of the ab1 file.

Wanjin Hu

roblanf commented 2 years ago

Thanks @wanjinhu, that's super useful to know.

@Kuanhao-Chao, maybe we should build in an ab1 file check routine prior to loading. E.g. something like:

Try to load the file with something that should work

If there's an error loading the file: abort with an error message we write, something like "Unable to load the ab1 file [filename], please double check that this file is a valid ab1 file and try again"

If there isn't an error loading, proceed to making sure we can extract the information we want. If there are any issues, we can give more nuanced error messages like: "Unable to extract [field name] from ab1 file [filename]"

We can probably just do all of this as part of the usual workflow, by adding these kinds of useful error messages at key points. What do you think @Kuanhao-Chao?

Kuanhao-Chao commented 2 years ago

Thanks @wanjinhu for sharing this useful information, and I hope new sangeranalyseR update is useful for you. Please let us if there are any feedbacks.

@roblanf, this sounds like a great idea! Currently, sangeranalyseR uses the ab1 file reading method from sangerseqR, and I can add this checking method on top of it to make it robuster.