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

constraint tree #200

Open
hjt1129 opened this issue Oct 23, 2024 · 11 comments
Open

constraint tree #200

hjt1129 opened this issue Oct 23, 2024 · 11 comments

Comments

@hjt1129
Copy link

hjt1129 commented Oct 23, 2024

hi,
I run the raxml-ng using SNP data, when i used four individuals (S1,S2,S3,S4) from one population as outgroup, they did not formed in one lineage. I used "--tree-constraint" to specify a constraint tree for these four individuals, the file content is "(S1,S2,S3,S4);", however, i comes the error "Segmentation fault (core dumped)". What's wrong with this? how can i take this four individuals into one lineage.
The executive command is "raxml-ng --all --msa ./074GSC_12535_no39_tab.min4.min4.phy --outgroup S40 S41 S43 --model TVM+G4+ASC_LEWIS --tree pars{10} --bs-trees 1000 --tree-constraint constraint.tree"

@amkozlov
Copy link
Owner

Please post your .raxml.log file as well as input data, and I will have a look.

@hjt1129
Copy link
Author

hjt1129 commented Oct 24, 2024 via email

@amkozlov
Copy link
Owner

1 please try the latest version: https://github.com/amkozlov/raxml-ng/releases/tag/1.2.2
2. outgroup taxa names must be separated by comma, e.g. --outgroup S40,S41,S43
3. if it still doesn't work, please attach 074GSC_12535_no39_tab.min4.min4.phy and constraint.mld files, and I'll have a look

@hjt1129
Copy link
Author

hjt1129 commented Oct 24, 2024 via email

@amkozlov
Copy link
Owner

unfortunately I don't see the attachments

@domivika
Copy link

Hello,

I've run into a similar issue as the author of the post. I get the "Segmentation fault (core dumped)" error when running the command with 2 threads:
raxml-ng --redo --msa results/fasta/family/67-of-79/aligned.fa --outgroup AAHYM041-16,AANIC173-10,AASFB349-10 --model GTR+G --tree-constraint results/fasta/family/67-of-79/remapped.tre --search --threads 2

and when running with 1 thread:
raxml-ng --redo --msa results/fasta/family/67-of-79/aligned.fa --outgroup AAHYM041-16,AANIC173-10,AASFB349-10 --model GTR+G --tree-constraint results/fasta/family/67-of-79/remapped.tre --search --threads 1
I get the following error:
free(): invalid pointer
Aborted (core dumped)

Please see the attached zip file for logs, trees, and other relevant files

Thank you!
raxml_files.zip

@amkozlov
Copy link
Owner

Hi Dominika,

thanks for reporting.

Your MSA has only 4 sequences, and your constraint tree has only 3 taxa. This means that only one topology is possible under the topological constraint.

Sure, raxml-ng should still process this trivial situation without failure, and I will fix it in the next version.
But for the time being, maybe you could just detect and handle such edge cases in your pipeline?

@domivika
Copy link

domivika commented Nov 11, 2024

Hello,

Thanks for your reply. In my pipeline, I simply skip files with insufficient number of aligned sequences (<4) for now. Also, if there is an error regarding the complex constraint tree like this:

[00:00:00] Loaded comprehensive constraint tree with 5 taxa
ERROR: You provided a comprehensive, fully-resolved tree as a topological constraint.
Since this is almost certainly not what you intended, RAxML-NG will now exit...

I simply copy the input tree to the output one for the sake of testing.

I think the problem lays somewhere else here. This is my snakemake rule for raxml tool:

rule run_raxml:
    input:
        alignment="results/fasta/family/{scatteritem}/aligned.fa",
        tree="results/fasta/family/{scatteritem}/remapped.tre"
    output:
        tree="results/fasta/family/{scatteritem}/aligned.fa.raxml.bestTree"
    params:
        model=config['model'],
        num_outgroups=config['outgroups']
    log: "logs/run_raxml/run_raxml-{scatteritem}.log"
    conda: "envs/raxml.yml"
    shell:
        """
        # Check the number of taxa in the alignment
        TAXON_COUNT=$(grep -c '>' {input.alignment})

        # Ensure there are at least 4 taxa
        if [ "$TAXON_COUNT" -lt 4 ]; then
            echo "Skipping RAxML-NG: alignment has only $TAXON_COUNT taxa, which is insufficient." > {log}
            echo "No tree generated due to insufficient taxa." > {output.tree}
            exit 0
        fi

        # Extract the outgroup names from the alignment file
        OG=$(grep '>' {input.alignment} | tail -{params.num_outgroups} | sed -e 's/>//' | tr '\n' ',')

        # Define a function to run RAxML-NG with error handling
        run_raxml () {{
            raxml-ng \
                --redo \
                --msa {input.alignment} \
                --outgroup $OG \
                --model {params.model} \
                --tree-constraint {input.tree} \
                --threads $1 \
                --search > {log} 2>&1
        }}

        # Check if the constraint tree file exists
        if [ -s {input.tree} ]; then
            run_raxml 20

            # Handle errors based on log output
            if grep -q "core oversubscription" {log}; then
                echo "Oversubscription detected; rerunning with fewer threads." >> {log}
                run_raxml 10
            elif grep -q "core dumped" {log}; then
                echo "Core dump detected, retrying with single-thread mode." >> {log}
                run_raxml 1
            elif grep -q "ERROR: You provided a comprehensive" {log}; then
                echo "Comprehensive constraint detected; copying input tree to output." >> {log}
                cp {input.tree} {output.tree}
            fi
        else
            # Run without constraint if not available
            raxml-ng \
                --redo \
                --msa {input.alignment} \
                --outgroup $OG \
                --model {params.model} \
                --threads 20 \
                --search > {log} 2>&1
        fi
        """

and I keep getting this core dumped error (only for few fasta files):

    environment: line 16: 4153872 Aborted                 (core dumped) raxml-ng --redo --msa results/fasta/family/67-of-79/aligned.fa --outgroup $OG --model GTR+G --tree-constraint results/fasta/family/67-of-79/remapped.tre --threads $1 --search > logs/run_raxml/run_raxml-67-of-79.log 2>&1

I tried digging into this issue, and apparently the program is trying to access the memory it doesn't have access to? I'm a bit confused, example: relevant reddit thread

Do you have any idea what is going on?

Thanks!
Dominika

@domivika
Copy link

Hi,

It seems like the issue is also similar to #152

@amkozlov
Copy link
Owner

Well, as I said, the original problem that leads to the core dump has to be fixed inside raxml-ng.

But as a quick workaround, I suggest you simply disable tree constraint (and probably also outgroup) if alignment has 4 taxa, since it makes little sense.

Maybe you could even skip 4-taxa MSAs altogether. Please note that there are only 2 possible alternative tree topologies with 4 taxa.

@domivika
Copy link

Okay, I understand! Will do as you suggest.
Thanks a lot for your quick answer. I'm looking forward to the next version!

Dominika

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

3 participants