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

thread '<unnamed>' panicked at 'called Result::unwrap() #4

Closed
joanocha opened this issue Mar 17, 2023 · 14 comments
Closed

thread '<unnamed>' panicked at 'called Result::unwrap() #4

joanocha opened this issue Mar 17, 2023 · 14 comments

Comments

@joanocha
Copy link

Hi,

I tried running the latest version of HiFiCNV and got the following error:

thread '' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/bam_scanner.rs:72:63

I tried to run with 1 thread, 20 threads or without specifying threads and I am still getting the same error. Any thoughts on what could be going on? It seems to be something rust-related and an error is being reported but the message does not really explain what is the underlying issue or the error.

Any help would be much appreciated!
Thanks
Joana

@ctsa
Copy link
Member

ctsa commented Mar 17, 2023

Thanks for describing the issue Joana,

The easiest way for us to help with this would be if you can share the log output, and ideally the data you're analyzing (or even better a minimized version of it). Please let me know and I can setup a share for you if this is possible.

If not, we can at least go ahead and get a better error message on that unwrap call, to help get some more specific information on what could be happening in this case.

@joanocha
Copy link
Author

So this is what I am running:

./hificnv --bam PACBIO_HPRC_bams_mapped2h38/HG00621.sorted.bam --ref human_GRCh38.p14/GCF_000001405.40_GRCh38.p14_genomic.fna --threads 20 --output-prefix HG00621

The HPRC PACBIO HiFi reads for S3/HG00621 were mapped to h38 using minimap2 as follows:
minimap2 -ax map-hifi -t 20 {ref_path} {input} | samtools view -q 10 -bT {ref_path} -o {output} #input here is PacBio HiFi reads
samtools sort -o {output} {input}
samtools merge -f {output} {input} #here the output will be the merging of all reads corresponding to sample HG00621
samtools addreplacerg -r SM:{wildcards.sample} -r ID:{wildcards.sample} -r PL:PACBIO -o {output} {input}
samtools sort -o {output} {input}
samtools index {output}

are there any specific requirements or params for minimap2 I would need to use? I used HG00621.sorted.bam to run deepVariant with the PacBIO model and it worked. Same to get vcfs for SV calling using other softwares like pbsv.

Here is the log info:

[2023-03-17][10:34:27][hificnv][INFO] Starting hificnv
[2023-03-17][10:34:27][hificnv][INFO] cmdline: ./hificnv --bam HG00621.sorted.bam --ref human_GRCh38.p14/GCF_000001405.40_GRCh38.p14_genomic.fna --threads 20 --output-prefix HG00621
[2023-03-17][10:34:27][hificnv][INFO] Running on 20 threads
[2023-03-17][10:34:27][hificnv][INFO] Reading reference genome from file 'human_GRCh38.p14/GCF_000001405.40_GRCh38.p14_genomic.fna'
[2023-03-17][10:34:40][hificnv][INFO] Processing alignment file 'HG00621.sorted.bam'

@joanocha
Copy link
Author

joanocha commented Mar 17, 2023

As a follow up:
I get 2 different errors based on the reference genome I use.

Using the sample example sample (HG00621), when Reference used for minimap2 is GCF_002880755.1_Clint_PTRv2_genomic.fna:
thread '' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/bam_scanner.rs:72:63

For the sampe sample, when Reference is GCF_000001405.40_GRCh38.p14_genomic.fna:
thread '' panicked at 'Method assumes alignment CIGAR strings use seq match/mismatch (=/X) instead of alignment match (M)', /usr/local/cargo/git/checkouts/rust-vc-utils-bd4e9cc518074f37/ff04dbb/src/bam_utils.rs:58:17

@ctsa
Copy link
Member

ctsa commented Mar 17, 2023

Thanks Joana,

The second issue is very clear -- in the short term you could work around this problem by remapping with pbmm2, which is our recommended read mapper for HiFi.

This brings up the issue that we haven't tested HiFiCNV for minimap2, and hadn't come up with a support policy yet, so we'll consider our options and clarify this soon.

For the first issue (PoisonError), I would expect to see it only as a secondary error message -- there typically should be an original panic/error message occurring first which leads to the failed unwrap later on. I think we can add some changes to the code to simplify and clarify the error messages for cases like this, but in the short term if you're able to spot the very first panic/error message in the log for this case, it might point to a more specific issue -- if all of these samples are mapped with minimap2, I wouldn't be surprised if the CIGAR string format was the complication for all of these samples.

@holtjma
Copy link
Collaborator

holtjma commented Mar 29, 2023

Hi @joanocha, this should be fixed with the latest release which can be found here: https://github.com/PacificBiosciences/HiFiCNV/releases/tag/v0.1.6

@holtjma holtjma closed this as completed Mar 29, 2023
@Gedofs
Copy link

Gedofs commented Mar 29, 2023

Thanks @holtjma I'll try this new version too

@joanocha
Copy link
Author

joanocha commented Apr 2, 2023

Hi!
Thank you for the new version! Indeed that issue was fixed! But now I have another:
thread 'main' panicked at 'Diploid chromosome regex '^(chr)?\d{1,2}$' does not match any sample chromosome names.', src/cli.rs:190:5
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

I just double checked and the input bams seem to match the chromosome names of the reference. The thing is that the chromosome names are not chr 1,2 but rather the NCBI codes NC_#####.

@ctsa
Copy link
Member

ctsa commented Apr 3, 2023

Hi @joanocha

HiFiCNV currently looks for a set of diploid autosomes to estimate the GC-bias of the sample. To do do it matches chromosome names against a regular expression which can be set on the cmdline:

        --cov-regex <REGEX>
            Regex used to select chromosomes for mean haploid coverage estimation. All selected
            chromosomes are assumed diploid
            
            [default: ^(chr)?\d{1,2}$]

For the case you describe, you could start by setting this argument so that all chromosomes are used for GC-bias correction by adding the following to your cmdline: --cov-regex .

We'll discuss possible changes to the gc-bias correction to see if this setting can be simplified out.

@Gedofs
Copy link

Gedofs commented Apr 3, 2023

I'm now running the newest release however I have a new issue:
thread 'main' panicked at 'Can't find chromosome 'chr11_KI270721v1_random' in reference genome.', src/gc_correction.rs:81:13. Is there a way to fox this?

@holtjma
Copy link
Collaborator

holtjma commented Apr 3, 2023

@Gedofs This error is only supposed to show up when a chromosome is encountered in the BAM file that is not present in your reference genome file. Can you verify that you are using the same reference file for both the upstream alignment and HiFiCNV? If so, it may be a good idea to open a separate issue so we can track it separate from this closed one.

@Gedofs
Copy link

Gedofs commented Apr 3, 2023 via email

@Gedofs
Copy link

Gedofs commented Apr 4, 2023 via email

@holtjma
Copy link
Collaborator

holtjma commented Apr 4, 2023

@Gedofs Can you make a new issue so we don't lose track of it in this closed issue? The problem you're experiencing seems unrelated to Joana's original problem.

@Gedofs
Copy link

Gedofs commented Apr 4, 2023 via email

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

4 participants