A logistic regression model is trained to recognise nosZ, the one gene on Earth that destroys nitrous oxide. It is built from 3,994 real copies of nosZ, 2,977 copies of 2 genes that look like it, nirK and coxB, and 8,804 ordinary bacterial genes. Here is every step, with the real numbers and the real code.
You can tell English from Spanish without reading a word. English is full of th and ing; Spanish is full of ll and ción. You are not reading it, you are noticing its habits.
A nosZ gene has habits too, so the model never has to read it. It chops the DNA into short runs of letters and counts them. Here are 24 letters out of a nosZ gene, and 24 out of an ordinary one.
20 runs, and all 20 of them different.
20 runs, but only 7 different ones.
GCGGC alone appears 6 times.
| Run | How many |
|---|---|
| AACAT | 1 |
| AAGTG | 1 |
| ACAAG | 1 |
| ACATC | 1 |
| AGTGG | 1 |
| ATCGA | 1 |
| CAAGG | 1 |
| CAAGT | 1 |
| CATCG | 1 |
| CGACA | 1 |
| CTGCA | 1 |
| GAACA | 1 |
| GACAA | 1 |
| GCAAG | 1 |
| GGAAC | 1 |
| GTGGA | 1 |
| TCGAC | 1 |
| TCTGC | 1 |
| TGCAA | 1 |
| TGGAA | 1 |
| Run | How many |
|---|---|
| GCGGC | 6 |
| CGGCG | 5 |
| GGCGG | 5 |
| ATCCG | 1 |
| CCGCG | 1 |
| CGCGG | 1 |
| TCCGC | 1 |
The model is given the real genes labelled yes and everything else labelled no. It counts the runs in all 15,775 of them and works out which runs tell the two apart. That is what the 3 lines below do, and it takes 26 seconds.
Now ask it about anything. 1.0 means certainly the gene, 0.0 certainly not.
Of 3,155 sequences held back and never shown to it, it got 3,142 right.
| atcgaca | +2.25 |
| gacagcca | +2.19 |
| acagccag | +2.07 |
| acagcca | +2.01 |
| tcgacag | +1.95 |
| tactgcac | +1.95 |
| gacagcc | +1.95 |
| acaagat | +1.91 |
| gcggc | -1.62 |
| ggcgc | -1.51 |
| gcgct | -1.41 |
| gcgcg | -1.26 |
| ggcgcg | -1.21 |
| cgcgg | -1.21 |
| ccgcc | -1.18 |
| cgcgc | -1.16 |
The right-hand runs are nearly all G and C, which is what ordinary Bradyrhizobium DNA is made of. Nobody told it that.
The model scores a short stretch of DNA, not a whole genome. So walk the genome 2,000 letters at a time and score each slice. That is 9,104 slices across 9,105,828 letters.
Out of 9,104 slices, 2 cross the line, and both sit on the gene. The dark mark is where the database says the gene is. Nobody told the computer that.
Every genome in the genus with a published assembly was read end to end. The scores split cleanly: the 13 that carry it score above 0.99, and the 27 that do not stay below 0.56. Nothing lands in between, which is what you want to see. A model that was guessing would smear species across the middle.
It was also checked against 3 strains a farmer can order, where microbiology already knew the answer and the model had never seen any of them. It got all 3 right, including CPAC 15, which has been sold across millions of hectares and is the one that cannot destroy N₂O.
| # | Species | Score | Carries the gene |
|---|---|---|---|
| 1 | Bradyrhizobium guangdongense | 0.9974 | yes |
| 2 | Bradyrhizobium forestalis | 0.9963 | yes |
| 3 | Bradyrhizobium nanningense | 0.9959 | yes |
| 4 | Bradyrhizobium nitroreducens | 0.9957 | yes |
| 5 | Bradyrhizobium frederickii | 0.9954 | yes |
| 6 | Bradyrhizobium neotropicale | 0.9951 | yes |
| 7 | Bradyrhizobium diazoefficiens | 0.9948 | yes |
| 8 | Bradyrhizobium ottawaense | 0.9945 | yes |
| 9 | Bradyrhizobium shewense | 0.9939 | yes |
| 10 | Bradyrhizobium stylosanthis | 0.9939 | yes |
| 11 | Bradyrhizobium oligotrophicum S58 | 0.9925 | yes |
| 12 | Bradyrhizobium lablabi | 0.9919 | yes |
| 13 | Bradyrhizobium centrolobii | 0.9901 | yes |
| 14 | Bradyrhizobium manausense | 0.6580 | no |
| 15 | Bradyrhizobium retamae | 0.6366 | no |
| 16 | Bradyrhizobium symbiodeficiens | 0.5538 | no |
| 17 | Bradyrhizobium cajani | 0.4967 | no |
| 18 | Bradyrhizobium huanghuaihaiense | 0.4917 | no |
| 19 | Bradyrhizobium zhanjiangense | 0.4803 | no |
| 20 | Bradyrhizobium sacchari | 0.4670 | no |
| 21 | Bradyrhizobium cosmicum | 0.4553 | no |
| 22 | Bradyrhizobium macuxiense | 0.4186 | no |
| 23 | Bradyrhizobium guangzhouense | 0.4081 | no |
| 24 | Bradyrhizobium valentinum | 0.3984 | no |
| 25 | Bradyrhizobium canariense | 0.3872 | no |
| 26 | Bradyrhizobium pachyrhizi | 0.3822 | no |
| 27 | Bradyrhizobium australiense | 0.3776 | no |
| 28 | Bradyrhizobium hipponense | 0.3760 | no |
| 29 | Bradyrhizobium erythrophlei | 0.3749 | no |
| 30 | Bradyrhizobium daqingense | 0.3660 | no |
| 31 | Bradyrhizobium betae | 0.3542 | no |
| 32 | Bradyrhizobium amphicarpaeae | 0.3481 | no |
| 33 | Bradyrhizobium cytisi | 0.3456 | no |
| 34 | Bradyrhizobium jicamae | 0.3446 | no |
| 35 | Bradyrhizobium rifense | 0.3421 | no |
| 36 | Bradyrhizobium uaiense | 0.3323 | no |
| 37 | Bradyrhizobium niftali | 0.3246 | no |
| 38 | Bradyrhizobium ivorense | 0.3011 | no |
| 39 | Bradyrhizobium icense | 0.2939 | no |
| 40 | Bradyrhizobium archetypum | 0.2885 | no |