Skip to content

Modify the calculation method of Nsite and Ssite in NG86 - #4556

Merged
mdehoon merged 2 commits into
biopython:masterfrom
JuseTiZ:NG86-NSsite
Dec 30, 2023
Merged

mdehoon merged 2 commits into
biopython:masterfrom
JuseTiZ:NG86-NSsite

Conversation

@JuseTiZ

@JuseTiZ JuseTiZ commented Dec 28, 2023 •

Copy link
Copy Markdown
Contributor
  • I hereby agree to dual licence this and any previous contributions under both
    the Biopython License Agreement AND the BSD 3-Clause License.

  • I have read the CONTRIBUTING.rst file, have run pre-commit
    locally, and understand that continuous integration checks will be used to
    confirm the Biopython unit tests and style checks pass with these changes.

  • I have added my name to the alphabetical contributors listings in the files
    NEWS.rst and CONTRIB.rst as part of this pull request, am listed
    already, or do not wish to be listed. (This acknowledgement is optional.)

If k represents the transition/transversion rate ratio, it seems that k may have been positioned incorrectly. If my understanding is incorrect, please feel free to correct it and close this pull request. Thank you!

@peterjc

peterjc commented Dec 28, 2023

Copy link
Copy Markdown
Member

What do you think @zruan ?

@mdehoon

mdehoon commented Dec 29, 2023

Copy link
Copy Markdown
Contributor

@JuseTiZ Would you have a reference showing that the transition/transversion rate ratio should be used?

@mdehoon

mdehoon commented Dec 29, 2023

Copy link
Copy Markdown
Contributor

Note that the same code appears in the newer Bio.Align.analysis module.

@JuseTiZ

JuseTiZ commented Dec 29, 2023

Copy link
Copy Markdown
Contributor Author

@JuseTiZ Would you have a reference showing that the transition/transversion rate ratio should be used?

@mdehoon

I consulted Ziheng Yang's 'Computational Molecular Evolution.' Specifically, in the second chapter, titled 'Models of amino acid and codon substitution,' under the section 'Estimation of synonymous and nonsynonymous substitution rates,' there is relevant information on this topic.

1

It's indicated that sites with higher mutation rates should have higher Ssite and Nsite values. This is important to maintain a balance in their contribution to the overall calculations of dN and dS.

I will add the same code in Bio.Align.analysis to this PR. However, I am still not sure if this is correct.

@JuseTiZ
JuseTiZ requested a review from mdehoon as a code owner December 29, 2023 02:22
@zruan

zruan commented Dec 29, 2023

Copy link
Copy Markdown
Contributor

This seems to be a bug in which the w (transition/transversion ratio) is not correctly placed.

@JuseTiZ can you please confirm that after the changes, the codonalign.codonseq._count_site_NG86(['TTT'], codon_table, k=2) reports the same number as shown in the table?

@JuseTiZ

JuseTiZ commented Dec 29, 2023

Copy link
Copy Markdown
Contributor Author

This seems to be a bug in which the w (transition/transversion ratio) is not correctly placed.

@JuseTiZ can you please confirm that after the changes, the codonalign.codonseq._count_site_NG86(['TTT'], codon_table, k=2) reports the same number as shown in the table?

@zruan Below is a demonstration, where _count_site_NG86_modified is a function I modified according to the method in the PR (that is, changing the position of k).

from Bio.codonalign import codonseq
from Bio.Data import CodonTable

codon_table = CodonTable.generic_by_id[1]
ssite, nsite = codonseq._count_site_NG86(['TTT'], codon_table, k=1)
ssite2, nsite2 = codonseq._count_site_NG86(['TTT'], codon_table, k=2)

print(f'Before modification:\nFor k=1 ssite {ssite:.2f} nsite {nsite:.2f}.\n'
      f'For k=2 ssite {ssite2:.2f} nsite {nsite2:.2f}.')

ssite, nsite = codonseq._count_site_NG86_modified(['TTT'], codon_table, k=1)
ssite2, nsite2 = codonseq._count_site_NG86_modified(['TTT'], codon_table, k=2)

print(f'After modification:\nFor k=1 ssite {ssite:.2f} nsite {nsite:.2f}.\n'
      f'For k=2 ssite {ssite2:.2f} nsite {nsite2:.2f}.')

The output of this demonstration is as follows:

Before modification:
For k=1 ssite 0.33 nsite 2.67.
For k=2 ssite 0.20 nsite 2.80.
After modification:
For k=1 ssite 0.33 nsite 2.67.
For k=2 ssite 0.50 nsite 2.50.

@zruan

zruan commented Dec 29, 2023

Copy link
Copy Markdown
Contributor

It looks like after the modification, the output of the function matches with what are shown in the table.

For k=1 ssite 0.33 (1/3) nsite 2.67 (8/3).
For k=2 ssite 0.50 (1/2) nsite 2.50 (5/2).

@mdehoon

mdehoon commented Dec 30, 2023

Copy link
Copy Markdown
Contributor

@zruan Should we accept this PR then?

@zruan

zruan commented Dec 30, 2023

Copy link
Copy Markdown
Contributor

@mdehoon Yes, we should. Maybe we should update the numbers in unittest as well?

@mdehoon

mdehoon commented Dec 30, 2023

Copy link
Copy Markdown
Contributor

@zruan The unit tests seem fine as is, as all tests passed.

@mdehoon
mdehoon merged commit dfcd208 into biopython:master Dec 30, 2023
@mdehoon

mdehoon commented Dec 30, 2023

Copy link
Copy Markdown
Contributor

Thank you.

@JuseTiZ
JuseTiZ deleted the NG86-NSsite branch December 31, 2023 04:23
peterjc added a commit to peterjc/biopython that referenced this pull request Feb 5, 2024
Original author Zheng Ruan and contributors tracked by
version control have agreed:

 - Adhemar Zerlotini (@azneto)
   biopython#1412 (comment)
 - Benjamin Vaisvil (@bvaisvil)
   biopython#1613
 - Carlos Pena (@carlosp420)
   biopython#898 (comment)
 - Chris Rands (@chris-rands)
   biopython#1301
 - Christian Brueffer (@cbrueffer)
   biopython#898 (comment)
 - Juse (@JuseTiZ)
   biopython#4556
 - Michiel de Hoon (@mdehoon)
   biopython#898 (comment)
 - Micky Yun Chan (@michiboo)
   biopython#1983
 - @morrme
   biopython#1172 (comment)
 - Neil P. (@npars)
   biopython#3937
 - Peter Cock (@peterjc)
   biopython#898 (comment)
 - Sergio Valqui (@svalqui)
   biopython#1749
 - Sujan Dulal (@Dsujan)
   biopython#2430
 - Travis Wrightsman (@twrightsman)
   biopython#898 (comment)
 - Zheng Ruan (@zruan)
   biopython#898 (comment)
peterjc added a commit that referenced this pull request Feb 5, 2024
Original author Zheng Ruan and contributors tracked by
version control have agreed:

 - Adhemar Zerlotini (@azneto)
   #1412 (comment)
 - Benjamin Vaisvil (@bvaisvil)
   #1613
 - Carlos Pena (@carlosp420)
   #898 (comment)
 - Chris Rands (@chris-rands)
   #1301
 - Christian Brueffer (@cbrueffer)
   #898 (comment)
 - Juse (@JuseTiZ)
   #4556
 - Michiel de Hoon (@mdehoon)
   #898 (comment)
 - Micky Yun Chan (@michiboo)
   #1983
 - @morrme
   #1172 (comment)
 - Neil P. (@npars)
   #3937
 - Peter Cock (@peterjc)
   #898 (comment)
 - Sergio Valqui (@svalqui)
   #1749
 - Sujan Dulal (@Dsujan)
   #2430
 - Travis Wrightsman (@twrightsman)
   #898 (comment)
 - Zheng Ruan (@zruan)
   #898 (comment)
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

Successfully merging this pull request may close these issues.

4 participants