# An "AttributeError: 'NoneType' object has no attribute 'shape'" when building phylogenetic tree using Augur

**URL:** <https://nextstrain.discourse.group/t/an-attributeerror-nonetype-object-has-no-attribute-shape-when-building-phylogenetic-tree-using-augur/401>\
**Category:** General\
**Created:** [March 8, 2021, 9:37am UTC](https://nextstrain.discourse.group/t/an-attributeerror-nonetype-object-has-no-attribute-shape-when-building-phylogenetic-tree-using-augur/401 "2021-03-08T09:37:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cloudy](https://avatars.discourse-cdn.com/v4/letter/c/ea5d25/32.png) [@Cloudy](https://nextstrain.discourse.group/u/Cloudy)\
**Post date:** [March 8, 2021, 9:37am UTC](https://nextstrain.discourse.group/t/an-attributeerror-nonetype-object-has-no-attribute-shape-when-building-phylogenetic-tree-using-augur/401/1 "2021-03-08T09:37:40Z")

</div>

Hello all,  
I am getting started with the Augur and currently building a phylogenetic tree on ncov. According to tutorial web [Augur: A bioinformatics toolkit for phylogenetic analysis — Augur documentation](https://docs.nextstrain.org/projects/augur/en/stable/index.html), I have built a tree newick file and am going to refine it and acquire the time tree file. However, many times as I tried there is an Error always accured that is " AttributeError: ‘NoneType’ object has no attribute ‘shape’ ".

The following lines are the augur command line be input and the specific of the error:

$ augur refine -a gisaid\_hcov-19\_2021\_02\_26\_02\_rename\_edit\_filted\_align.fasta  
-t gisaid\_hcov-19\_2021\_02\_26\_02\_rename\_edit\_filted\_align.tree  
–metadata gisaid\_hcov-19\_2021\_02\_26\_02\_matadata\_sorted.tsv  
–output-tree gisaid\_hcov-19\_2021\_02\_26\_02\_rename\_edit\_filted\_align\_refine.tree  
–output-node-data gisaid\_hcov-19\_2021\_02\_26\_02\_rename\_edit\_filted\_align\_nodedata  
–timetree  
–coalescent float  
–date-confidence  
–vcf-reference EPI\_ISL\_402125.fasta

augur refine is using TreeTime version 0.8.1

13.20 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/101/2020

15.32 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/339/2020

15.33 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/226/2020

15.34 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/98/2020

15.36 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/295/2020

15.37 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/29/2020

15.38 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/30/2020

15.39 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/99/2020

15.40 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/08/2020

15.41 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/32/2020

15.43 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/68/2020

15.44 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/33/2020

15.45 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/03/2020

15.46 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/319/2020

15.47 \*\*\*WARNING: TreeAnc.\_attach\_sequences\_to\_nodes: NO SEQUENCE FOR LEAF:  
hCoV-19/Lu\_an/49/2020

15.49 \*\*\*WARNING: TreeAnc: 15 nodes don’t have a matching sequence in the  
alignment. POSSIBLE ERROR.

17.06 WARNING: Previous versions of TreeTime (\<0.7.0) RECONSTRUCTED sequences of  
tips at positions with AMBIGUOUS bases. This resulted in unexpected  
behavior is some cases and is no longer done by default. If you want to  
replace those ambiguous sites with their most likely state, rerun with  
`reconstruct_tip_states=True` or `--reconstruct-tip-states`.  
Traceback (most recent call last):  
File “/home/yt5266/miniconda3/envs/nextstrain/bin/augur”, line 8, in   
sys.exit(main())  
File “/home/yt5266/miniconda3/envs/nextstrain/lib/python3.6/site-packages/augur/ **main**.py”, line 10, in main  
return augur.run( argv[1:] )  
File “/home/yt5266/miniconda3/envs/nextstrain/lib/python3.6/site-packages/augur/ **init**.py”, line 75, in run  
return args. **command**.run(args)  
File “/home/yt5266/miniconda3/envs/nextstrain/lib/python3.6/site-packages/augur/refine.py”, line 214, in run  
covariance=args.covariance, resolve\_polytomies=(not args.keep\_polytomies))  
File “/home/yt5266/miniconda3/envs/nextstrain/lib/python3.6/site-packages/augur/refine.py”, line 70, in refine  
vary\_rate=vary\_rate, use\_covariation=covariance, \*\*kwarks)  
File “/home/yt5266/miniconda3/envs/nextstrain/lib/python3.6/site-packages/treetime/treetime.py”, line 156, in run  
max\_iter=1, prune\_short=True, \*\*seq\_kwargs)  
File “/home/yt5266/miniconda3/envs/nextstrain/lib/python3.6/site-packages/treetime/treeanc.py”, line 1305, in optimize\_tree  
self.optimize\_branch\_len(verbose=0, store\_old=False, mode=branch\_length\_mode)  
File “/home/yt5266/miniconda3/envs/nextstrain/lib/python3.6/site-packages/treetime/treeanc.py”, line 1074, in optimize\_branch\_len  
return self.optimize\_branch\_lengths\_joint(\*\*kwargs)  
File “/home/yt5266/miniconda3/envs/nextstrain/lib/python3.6/site-packages/treetime/treeanc.py”, line 1117, in optimize\_branch\_lengths\_joint  
new\_len = max(0,self.optimal\_branch\_length(node))  
File “/home/yt5266/miniconda3/envs/nextstrain/lib/python3.6/site-packages/treetime/treeanc.py”, line 1158, in optimal\_branch\_length  
self.add\_branch\_state(node)  
File “/home/yt5266/miniconda3/envs/nextstrain/lib/python3.6/site-packages/treetime/treeanc.py”, line 1065, in add\_branch\_state  
ignore\_gaps = self.ignore\_gaps)  
File “/home/yt5266/miniconda3/envs/nextstrain/lib/python3.6/site-packages/treetime/gtr.py”, line 606, in state\_pair  
if seq\_ch.shape != seq\_p.shape:  
AttributeError: ‘NoneType’ object has no attribute ‘shape’

I have tried to delete the input of “–treetime” and the Error doesn’t appear. However the tree file with according time is exactly what I want thus I have to run with it.

May anyone show me how to fix it out? Many appreciate and thanks!

Yuntian Bai

---

<div class="post-metadata">

**Author:** ![Cloudy](https://avatars.discourse-cdn.com/v4/letter/c/ea5d25/32.png) [@Cloudy](https://nextstrain.discourse.group/u/Cloudy)\
**Post date:** [March 8, 2021, 9:44am UTC](https://nextstrain.discourse.group/t/an-attributeerror-nonetype-object-has-no-attribute-shape-when-building-phylogenetic-tree-using-augur/401/2 "2021-03-08T09:44:44Z")

</div>

By the way, I did a “test” run using a 49 sequnences fasta file to see if it’s applicable. I did get the treetime file I want in that 49 test. Yet this time I confront with this error with my larger 1500 sequences fasta.I hope this information could be useful.

---

<div class="post-metadata">

**Author:** ![rneher](https://yyz1.discourse-cdn.com/flex031/user_avatar/nextstrain.discourse.group/rneher/32/20_2.png) [@rneher](https://nextstrain.discourse.group/u/rneher)\
**Post date:** [March 8, 2021, 10:09am UTC](https://nextstrain.discourse.group/t/an-attributeerror-nonetype-object-has-no-attribute-shape-when-building-phylogenetic-tree-using-augur/401/3 "2021-03-08T10:09:26Z")

</div>

We have run into this as well. The problem is that there are sequences called “Lu`an” or “Lu’an” which during tree building get renamed to “Lu\_an”. Then augur can’t match sequences and taxa in the tree and fails (it needs sequences to infer a time tree).

If you rename “Lu’an” to “Lu\_an” in your sequences and metadata, it should work.

---

<div class="post-metadata">

**Author:** ![james](https://yyz1.discourse-cdn.com/flex031/user_avatar/nextstrain.discourse.group/james/32/11_2.png) [@james](https://nextstrain.discourse.group/u/james)\
**Post date:** [March 8, 2021, 10:58pm UTC](https://nextstrain.discourse.group/t/an-attributeerror-nonetype-object-has-no-attribute-shape-when-building-phylogenetic-tree-using-augur/401/4 "2021-03-08T22:58:36Z")

</div>

See also [this discussion thread](https://nextstrain.discourse.group/t/error-unsupported-rooting-mechanisms-or-root-not-found/381/3) which had the same problem.

---

<div class="post-metadata">

**Author:** ![Cloudy](https://avatars.discourse-cdn.com/v4/letter/c/ea5d25/32.png) [@Cloudy](https://nextstrain.discourse.group/u/Cloudy)\
**Post date:** [March 9, 2021, 8:35am UTC](https://nextstrain.discourse.group/t/an-attributeerror-nonetype-object-has-no-attribute-shape-when-building-phylogenetic-tree-using-augur/401/5 "2021-03-09T08:35:55Z")

</div>

Thank you @rneher @james both. The tree file has generated successfally when sequences with “Lu’an” were dropped due to your insrtuctions. I really appreciate your help!

Now as I acquire the tree and nodedata files out from augur refine,I run the augur export to get json file and drag it into [auspice.us](http://auspice.us). There is the tree with timeline yet with no mutations or clades info on it. So I made a run of augur ancestral and get another json file by augur export, which shows null in web [auspice.us](http://auspice.us). I wonder how could I combine these result files into one phylogenetic tree similar to the one displayed on Nextstrain main page( [auspice](https://nextstrain.org/ncov/global))?

Much appreciate to every assistance!

---

<div class="post-metadata">

**Author:** ![Cloudy](https://avatars.discourse-cdn.com/v4/letter/c/ea5d25/32.png) [@Cloudy](https://nextstrain.discourse.group/u/Cloudy)\
**Post date:** [March 9, 2021, 9:05am UTC](https://nextstrain.discourse.group/t/an-attributeerror-nonetype-object-has-no-attribute-shape-when-building-phylogenetic-tree-using-augur/401/6 "2021-03-09T09:05:32Z")

</div>

I didn’t find the tutorial of Zika virus yet. Now I am running the tutorial to see how it works. Thank you again!

---

<div class="post-metadata">

**Author:** ![rneher](https://yyz1.discourse-cdn.com/flex031/user_avatar/nextstrain.discourse.group/rneher/32/20_2.png) [@rneher](https://nextstrain.discourse.group/u/rneher)\
**Post date:** [March 9, 2021, 12:06pm UTC](https://nextstrain.discourse.group/t/an-attributeerror-nonetype-object-has-no-attribute-shape-when-building-phylogenetic-tree-using-augur/401/7 "2021-03-09T12:06:02Z")

</div>

I think you need to tell us more what you are actually running for us to help you. In order to see mutations, you need to do ancestral reconstruction (`augur ancestral`) and include the result in the export.

you can find the tutorials here:  
[https://docs.nextstrain.org/en/latest/tutorials/index.html](https://docs.nextstrain.org/en/latest/tutorials/index.html)
