<p>Criteria, matrix. There must be a blank line between the last sample name and the start of the matrix. Also better to use #mega.</p>
<p>The tree from the matrix in the question is.</p>
<p><a href="https://i.sstatic.net/FRhO4.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/FRhO4.png" alt="enter image description here" /></a></p>
<p>It's simply the carriage returns <strong>must</strong> by in Windows format <code>\r</code> (even if its Linux or Mac) and <strong>not</strong> Mac or Linux <code>\n</code>. In Mac the converter is BBEdit.</p>

CC BY-SA 4.0
2023-10-13T18:53:04.757Z
Okay I edited the original post again with what I have - hopefully this helps. I changed it to a lower-left matrix and I was able to make a plot using this matrix with R but I want to see how it works with MegaX
rimo
CC BY-SA 4.0
2023-10-14T01:29:17.387Z
Okay it's done. Please do remember to upvote/accept this and the original answer to your first question from where this question originates.
M__
CC BY-SA 4.0
2023-10-16T15:59:59.350Z
Oh my goodness such a simple solution - thank you so much! I downloaded BBEdit and converted the file to a Windows (CRLF) `.meg` file and that worked!
rimo
CC BY-SA 4.0
2023-10-16T21:38:46.340Z
Thanks @rimo good to know it worked. Mega was originally written as a Windows program - thats why I suspected the carriage return format. When a developer changes platform there's always "carry-over" from the previous code.
M__
CC BY-SA 4.0
2023-10-13T00:42:38.480Z
2023-10-14T01:28:16.340Z
2023-10-14T01:28:16.340Z
M__
<p>I have a pairwise matrix that I've manually formatted into a &quot;.mega&quot; file following the guide in the MegaX documentation but when I go to import it into the application it gives this error:</p>
<pre><code>Unable to find the command terminator '
' (in line 48)
</code></pre>
<p>I don't understand what the terminator is supposed to be I can't find anything in the documentation or online. This is what my file looks like:</p>
<pre><code>#mega
TITLE: Lower-left triangular matrix

#sample1
#sample2
#sample3
#sample4
#sample5
#sample6
#sample7
#sample8
#sample9
#sample10
#sample11
#sample12
#sample13
#sample14
#sample15
#sample16
#sample17
#sample18
#sample19
#sample20
#sample21
#sample22
        
6779.024
4010.596    5085.012
4444.925    3965.719    3597.515
3824.67     4435.878    2140.942    2855.545
2698.035    5877.724    4274.36     3721.735    3562.716
5746.71     4991.678    3103.77     4587.394    3318.78     6141.058
2898.099    7345.178    5461.126    5000.322    4846.293    2354.302    7366.433
4667.862    2949.764    3986.194    2832.598    3118.544    3551.237    5007.972    5056.938
3956.69     5110.169    2489.003    3530.347    2310.696    4285.076    3286.188    5301.894    3994.313
4086.841    5636.588    2851.673    3681.433    3078.399    4197.933    4416.542    5139.341    4347.211    3250.879
3595.868    6237.556    3924.761    3907.091    3624.064    3081.475    5770.594    3985.626    4223.117    4013.377    3136.24
4574.567    5763.568    2420.15     4433.579    3203.997    5015.929    3445.061    6063.541    4820.971    3131.669    2940.224    4132.314
4621.723    3265.735    3518.476    2528.629    2685.442    3581.311    4361.296    5144.475    2322.969    3536.469    3942.852    4218.651    4431.758
4914.659    3750.498    2719.845    3117.886    2456.598    4411.935    3294.878    5908.595    3261.36     3157.398    3657.63     4540.83     3583.543    2199.326
5662.093    3090.623    3190.918    3289.562    2772.944    5317.999    2559.264    6786.94     3426.171    3247.437    4233.766    5294.141    3960.851    2656.578    2155.925
5559.707    3073.796    4997.709    3838.601    4294.455    4486.788    5728.029    5962.611    2303.294    5051.106    5270.304    5020.468    5639.198    3504.092    4111.158    4282.95
3906.494    4028.613    3618.28     2618.348    2835.36     2743.097    4941.507    4259.628    2191.873    3599.004    3847.302    3506.872    4432.612    2061.23     2947.972    3583.198    3342.373
6582.561    1663.359    4830.862    3730.956    4161.803    5594.268    4860.298    7160.793    2675.27     4859.183    5448.895    5895.575    5537.159    3011.78     3374.505    2881.87     2979.42     3464.931
4706.715    4004.427    4618.035    3537.473    3842.462    3773.964    5703.134    5002.92     2263.311    4592.613    4872.922    4301.443    5290.578    3530.202    4175.393    4494.308    2427.841    2677.65     3599.691
5703.386    2214.959    4515.044    3273.191    3766.439    4681.361    5022.943    6197.46     1837.686    4544.365    5026.108    5096.364    5257.581    2833.977    3419.825    3267.254    2034.999    2778.249    1661.474    2332.169
6689.288    11865.223   8990.382    9113.452    8897.297    7007.562    10983.956   6142.025    9502.64     9014.072    8056.924    6431.134    8821.925    9843.732    10166.579   11038.532   10009.974   8748.955    11573.491   8952.942    10488.639
</code></pre>
<p><strong>EDIT:</strong>
I copied the contents of the <code>.meg</code> file over to an Excel sheet to make it easier to see but I changed the <code>#Mega</code> to <code>#mega</code> and I made sure to only include the correct elements (there are 22 samples in total, only 21 values present in the first line of the matrix). I also made sure to keep a line between the last sample name and the first value of the matrix. However, it's <em>still</em> giving me the same error.</p>
<p>Is there something I'm supposed to add at the end of the file to make it read the file correctly? I'm  trying to import this distance matrix so I can generate a NJ tree. I'm not sure what I'm doing differently than what is mentioned <a href="https://www.megasoftware.net/mega1_manual/DataFormat.html" rel="nofollow noreferrer">here</a>.</p>

<phylogenetics><phylogeny><megax><distance-matrix><pairwise>
MegaX Pairwise Matrix Error
# MegaX Pairwise Matrix Error

(Asked by: username_0 on 2023-10-12)

I have a pairwise matrix that I've manually formatted into a ".mega" file following the guide in the MegaX documentation but when I go to import it into the application it gives this error:
Unable to find the command terminator '
' (in line 48)

I don't understand what the terminator is supposed to be I can't find anything in the documentation or online. This is what my file looks like:
#mega
TITLE: Lower-left triangular matrix

#sample1
#sample2
#sample3
#sample4
#sample5
#sample6
#sample7
#sample8
#sample9
#sample10
#sample11
#sample12
#sample13
#sample14
#sample15
#sample16
#sample17
#sample18
#sample19
#sample20
#sample21
#sample22
        
6779.024
4010.596    5085.012
4444.925    3965.719    3597.515
3824.67     4435.878    2140.942    2855.545
2698.035    5877.724    4274.36     3721.735    3562.716
5746.71     4991.678    3103.77     4587.394    3318.78     6141.058
2898.099    7345.178    5461.126    5000.322    4846.293    2354.302    7366.433
4667.862    2949.764    3986.194    2832.598    3118.544    3551.237    5007.972    5056.938
3956.69     5110.169    2489.003    3530.347    2310.696    4285.076    3286.188    5301.894    3994.313
4086.841    5636.588    2851.673    3681.433    3078.399    4197.933    4416.542    5139.341    4347.211    3250.879
3595.868    6237.556    3924.761    3907.091    3624.064    3081.475    5770.594    3985.626    4223.117    4013.377    3136.24
4574.567    5763.568    2420.15     4433.579    3203.997    5015.929    3445.061    6063.541    4820.971    3131.669    2940.224    4132.314
4621.723    3265.735    3518.476    2528.629    2685.442    3581.311    4361.296    5144.475    2322.969    3536.469    3942.852    4218.651    4431.758
4914.659    3750.498    2719.845    3117.886    2456.598    4411.935    3294.878    5908.595    3261.36     3157.398    3657.63     4540.83     3583.543    2199.326
5662.093    3090.623    3190.918    3289.562    2772.944    5317.999    2559.264    6786.94     3426.171    3247.437    4233.766    5294.141    3960.851    2656.578    2155.925
5559.707    3073.796    4997.709    3838.601    4294.455    4486.788    5728.029    5962.611    2303.294    5051.106    5270.304    5020.468    5639.198    3504.092    4111.158    4282.95
3906.494    4028.613    3618.28     2618.348    2835.36     2743.097    4941.507    4259.628    2191.873    3599.004    3847.302    3506.872    4432.612    2061.23     2947.972    3583.198    3342.373
6582.561    1663.359    4830.862    3730.956    4161.803    5594.268    4860.298    7160.793    2675.27     4859.183    5448.895    5895.575    5537.159    3011.78     3374.505    2881.87     2979.42     3464.931
4706.715    4004.427    4618.035    3537.473    3842.462    3773.964    5703.134    5002.92     2263.311    4592.613    4872.922    4301.443    5290.578    3530.202    4175.393    4494.308    2427.841    2677.65     3599.691
5703.386    2214.959    4515.044    3273.191    3766.439    4681.361    5022.943    6197.46     1837.686    4544.365    5026.108    5096.364    5257.581    2833.977    3419.825    3267.254    2034.999    2778.249    1661.474    2332.169
6689.288    11865.223   8990.382    9113.452    8897.297    7007.562    10983.956   6142.025    9502.64     9014.072    8056.924    6431.134    8821.925    9843.732    10166.579   11038.532   10009.974   8748.955    11573.491   8952.942    10488.639

EDIT:
I copied the contents of the .meg file over to an Excel sheet to make it easier to see but I changed the #Mega to #mega and I made sure to only include the correct elements (there are 22 samples in total, only 21 values present in the first line of the matrix). I also made sure to keep a line between the last sample name and the first value of the matrix. However, it's still giving me the same error.
Is there something I'm supposed to add at the end of the file to make it read the file correctly? I'm  trying to import this distance matrix so I can generate a NJ tree. I'm not sure what I'm doing differently than what is mentioned here.

**Tags:** phylogenetics, phylogeny, megax, distance-matrix, pairwise

---

## 1 answers

### Answer by username_1 on 2023-10-13. Score: 1 | Accepted answer

Criteria, matrix. There must be a blank line between the last sample name and the start of the matrix. Also better to use #mega.

The tree from the matrix in the question is.

[![enter image description here](https://i.sstatic.net/FRhO4.png)](https://i.sstatic.net/FRhO4.png)

It's simply the carriage returns **must** by in Windows format `\r` (even if its Linux or Mac) and **not** Mac or Linux `\n`. In Mac the converter is BBEdit.

> **Comments:**
> **username_0**: Okay I edited the original post again with what I have - hopefully this helps. I changed it to a lower-left matrix and I was able to make a plot using this matrix with R but I want to see how it works with MegaX  
> **username_1**: Okay it's done. Please do remember to upvote/accept this and the original answer to your first question from where this question originates.  
> **username_0**: Oh my goodness such a simple solution - thank you so much! I downloaded BBEdit and converted the file to a Windows (CRLF) `.meg` file and that worked!  
> **username_1**: Thanks @rimo good to know it worked. Mega was originally written as a Windows program - thats why I suspected the carriage return format. When a developer changes platform there's always "carry-over" from the previous code.  

---

