> For the complete documentation index, see [llms.txt](https://zpliu.gitbook.io/booknote/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zpliu.gitbook.io/booknote/hi-c/pangenome/ji-yin-zu-jian-jie-gou-bian-yi-jian-ding.md).

# 鉴定两个基因组之间重排

> SyRI uses whole genome alignments as input. Users can use any aligner of their choice. SyRI accepts alignment input in SAM/BAM format or in a `tab-separated value` format with [CIGAR](https://samtools.github.io/hts-specs/SAMv1.pdf) string information for each alignment. If the user wants to use [MUMmer](http://mummer.sourceforge.net/), then `.delta` file can be used in place of CIGAR strings. See [fileformat](https://schneebergerlab.github.io/syri/fileformat.html) for more information.

当使用MUMer的结果作为软件的输入的时候，最后一列比对情况的代码可以使用`.delta`文件代替。

## 1.首先使用`MUMER`获取全基因组的比对结果

> 将会生成一个`out.delta`文件

* refgenome 是当做参考基因组
* qrygenome 当做查询的基因组

```bash
nucmer --maxmatch -c 500 -b 500 -l 100 refgenome qrygenome;
```

## 2.过滤比对的结果和转化格式

* 使用`delta-filter`过滤结果
* `show-coords`将结果转化成TAB分割的文件

```bash
delta-filter -m -i 90 -l 100 out.delta > out_m_i90_l100.delta; 
show-coords -THrd out_m_i90_l100.delta > out_m_i90_l100.coords;
#合并所有染色体的coords文件以及delta文件
cat *coords >A2_vs_E1_filter.coords
cat *delta_filter >A2_vs_E1_filter.delta
##只保留同源染色体间的共线性，之前没有用`-i -l`参数
```

## 3.鉴定染色质间的重排

> 官方文档: <https://schneebergerlab.github.io/syri/example.html>

需要两个基因组的比对结果和基因组的序列信息，用于鉴定结构变异和重排以及局部变异(SNP、indel、CNV等)。

* `-c`两个基因组得到的结构变异坐标文件
* `-r`A基因组的序列文件
* `-q`B基因组的序列文件
* `-d` MUMER得到的`.delta`文件
* `nc`核心数目
* `-k`保留中间文件

```bash
##鉴定染色质的重排和共线性区域
syri  -c A2_A1.coords -r /public/home/cotton/public_data/GWAS_Fiber_ljy/HAU_Genome_Updated/A2/A2.Chr.fa -q /public/home/cotton/public_data/GWAS_Fiber_ljy/HAU_Genome_Updated/A1/A1.Chr.fa -d A2_A1_filter.delta --nc 2 --all -k
```

> 两个基因组中的同源染色体需要来自同一条链。如果染色体来自不同的链，则染色体之间的比对将被颠倒。由于SyRI找共线性区域然后检查同向的比对，因此它将无法找到共线性区域，并且可能会崩溃。 该问题的当前解决方案是手动检查alignments。**如果同源染色体之间的大多数比对是反向的，则查询基因组中的染色体需要反向互补**。**然后，需要将校正后的查询基因组与参考基因组进行比对**。我们正在研究一种可以生成点图以自动识别和反向互补此类反向染色体的方法。
>
> <https://www.jianshu.com/p/3571d7019fb7>

```bash
##统计需要反向互补的染色体
awk '{a[$10$11][$9]+=1}END{for(i in a){print i"\t"a[i][1]"\t"a[i][-1]}}' A2_vs_E1_filter.coords_1
'''
            正链数      反链数
Chr07Chr07    1327    4589
Chr06Chr06    1622    4725
Chr05Chr05    1077    6211
Chr04Chr04    1546    3986
'''
```

## 4.计算染色体共线性分化指数
