# Fixation index (FST)

Subpopulation 1 Subpopulation 2 Subpopulation 3 Total
Genotype AA 125 50 100
Aa 250 30 500
aa 125 20 400
Number of individual 500 100 1000 1600
Number of alleles 1000 200 2000 3200
Step 1. Calculate the gene   (allele) frequencies
Observed allele frequency A (p) (125*2+250)/1000=0.5 (50*2+30)/200=0.65 (2*100+500)/2000=0.35
a (q) 0.5 0.35 0.65
Step 2. Calculate the expected   genotypic counts under Hardy-Weinberg Equilibrium, and then calculate the   excess or deficiency of homozygotes in each subpopulation.
Summary of homozygote deficiency or excess relative to HWE:
Pop. 1. Observed = Expected: perfect fit
Pop. 2. Excess of 15.5 homozygotes: some inbreeding
Pop. 3. Deficiency of 45 homozygotes: outbred or   experiencing a Wahlund effect (isolate breaking).
Expected allele frequency AA 500*0.5^2 = 125 (= observed) 100*0.65^2 = 42.25 (observed has excess of 7.75) 1,000*0.35^2 = 122.5   (observed has deficiency of 22.5)
Aa 500*2*0.5*0.5 = 250 (=   observed) 100*2*0.65*0.35 = 45.5 (observed has deficit of 15.5) 1,000*2*0.65*0.35 = 455   (observed has excess of 45)
aa 500*0.5^2 = 125 (= observed) 100*0.35^2 = 12.25 (observed has excess of 7.75) 1,000*0.35^2 = 422.5   (observed has deficiency of 22.5)
Step 3. Calculate the local   observed heterozygosities of each subpopulation (we will call them Hobs s,   where the s subscript refers to the sth of n populations — 3 in this   example).
Local observed   heterozygosities 250/500 = 0.5 (Hobs 1) 30/100 = 0.3 (Hobs 2) 500/1000 = 0.5(Hobs 3)
Step 4. Calculate the local   expected heterozygosity, or gene diversity, of each subpopulation
Hexp = 2pq
Local expected   heterozygosity 2*0.5*0.5=0.5 (Hexp 1) 2*0.65*3.5=0.455 (Hexp 2) 2*0.35*0.65=0.455 (Hexp 2)
Step 5. Calculate the local   inbreeding coefficient of each subpopulation
F = (Hexps -Hobs)/Hexp
[positive F means fewer heterozygotes than expected indicates   inbreeding]
[negative F means more heterozygotes   than expected means excess outbreeding]
F1=(0.5—0.5)/0.5=0 F2=(0.455—0.3)/0.455=0.341 F3=(0.455—0.5)/0.455=-0.099
Step 6. and 7. Calculate p-bar   (p-bar, the frequency of allele A) over the total population.
Calculate q-bar (q-bar, the frequency of allele a) over the total   population.
Check: p-bar + q-bar = 1.0
the frequency of allele over the total population p-bar (0.5*1000+0.65*200+0.35*2000)/3200=0.4156
q-bar (0.5*1000+0.35*200+0.65*2000)/3200=0.5844
Step 8. Calculate the global   heterozygosity indices (over Individuals, Subpopulations and Total   population)
HI based on observed heterozygosities in individuals in subpopulations
HS based on expected heterozygosities in subpopulations
HT based on expected heterozygosities for overall total population
HI (observed) (0.5*500+0.3*100+0.5*1000)/1600=0.4875
HS (expected) (0.5*500+0.455*100+0.455*1000)/1600=0.4691
HT (in overall total population) 2*p-bar *q-bar    = 2 * 0.4156 * 0.5844 = 0.4858
Step 9. Calculate the global   F-statistics
Compare and contrast the global FISbelow with the “local inbreeding   coefficient” Fs of Step 5.
Here we are using a weighted average of the individual heterozygosities   over all the subpopulations.
Both FIS and Fs are, however, based   on the observed heterozygosities,
whereas FST and FIT are based   on expected heterozygosities.
FIS (Hs-Hi)/Hs=(0.4691-0.4875)/0.4691=-0.0393
FST (Ht-Hs)/Ht=(0.4858-0.4691)/0.4858=-0.0344
FIT (Ht-Hi)/Ht=(0.4858-0.4875)/0.4858=-0.0036
Step 10 conclusions Finally, draw some   conclusions about the genetic structure of the population and its   subpopulations.
1) One of the possible HWE   conclusions we could make:
Pop. 1 is consistent with HWE (results of Step 2)
2) Two of the possible “local   inbreeding” conclusions we could make from Step 5:
Pop. 2 is inbred (results of Step 5), and
Pop. 3 may have disassortative mating or be experiencing a Wahlund effect   (more heterozygotes than expected).
3) Conclusion concerning overall   degree of genetic differentiation (FST)
Subdivision of populations, possibly due to genetic drift,
accounts for approx. 3.4% of the total genetic variation
(result of Eqn FST.8 FST   calculation in Step 9),
4) No excess or deficiency of   heterozygotes over the total population (FIT    is nearly zero).

# 甲基化芯片中的M值和B值

M值和B值的计算公式

M值和B值的对应关系

## The histograms of Beta-value (left) and M-value (right) (27578 interrogated CpG sites in total)

M值和B值的分布

minfi包有getM和getBeta来分别计算M-values和Beta-values，包的作者认为，

• M-values具有更好的统计特性，更适合用于进行下游的统计分析（差异分析等）
• Beta-values更加容易解释，更能说明生物学上的意义

一般来说，具体的β值的意义是：

• 任何等于或大于0.6的β值都被认为是完全甲基化的。
• 任何等于或小于0.2的β值被认为是完全未甲基化的。
• β值在0.2和0.6之间被认为是部分甲基化的。
• 参考：

https://zhuanlan.zhihu.com/p/108364645

# Failed to mount 大容量的RAID组

我们的存储服务器有两组RAID，容量均大于150T，我在mount的时候，提示我

```NTFS signature is missing.
Failed to mount '/dev/sdc': Invalid argument
The device '/dev/sdc' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?```

是因为没有分区导致的，分区之后就可以了。分区的命令

```# 使用parted命令进行分区,等同parted; select /dev/sdc
parted /dev/sdc

# 创建分区表
mklabel gpt

# 使用print命令查看当前分区情况
print

# 留1M的空余空间，目的是为了让数据块整齐，提高磁盘的运行效率, -1表示分区的结尾  意思是划分整个硬盘空间为主分区
mkpart primary 1 -1

p  # print的简写

# 使用q命令退出,
quit

# 退出之后会提示
会提示Information: You may need to update /etc/fstab.

# 格式化分区，为分区写入文件系统,格式为ext4
mkfs –t ext4 /dev/sdc1 # 格式化分区

# 使用blkid命令，找到 UUID，然后编辑 /etc/fstab，实现自动挂载
vim /etc/fstab

UUID=******	directory	ext4	defaults	0	0
```

参考:

https://www.cnblogs.com/kreo/p/9462641.html

https://www.cnblogs.com/saszhuqing/p/9964262.html

# 分类模型的性能评估

最常用的就是灵敏度和特异性，不过还有其他的，比如阴性预测值(negative predictive value, NPV)。

通常，先画一个ROC曲线，计算曲线下面积。ROC上的每个点是特定阈值下，分类的sensitivity和specificity，没多点连起来组成ROC，曲线下面积就是AUC。面积越大越好，如果AUC是1，说明模型能够完全区分要预测的类别。

如果不是1，就要考虑阈值取哪里比较好，这里就涉及到Youden index。Youden index 其实就是为了找到使得sensitivity和specificity之和最大max(sensitivities+specificities)的阈值。

另外就是考虑其他指标来评估分类模型的性能：specificity, sensitivity, accuracy, npv, ppv, precision, recall, tpr, fpr, tnr, fnr, fdr。这些指标可谓琳琅满目，不过这之间有重复的，如下，都是基于tn（真阴）, tp（真阳）, fn（假阴）, fp（假阳）的个数进行计算。

 预测 P N 实际 P TP FN N FP TN

因为经常用到，就罗列了一下。

具体描述 公式 别名
tn True negative count真阴数
tp True positive count真阳数
fn False negative count假阴数
fp False positive count假阳数
specificity Specificity特异度 tn / (tn + fp) tnr
sensitivity Sensitivity灵敏度 tp / (tp + fn) recall, tpr
accuracy Accuracy正确率 (tp + tn) / N
npv Negative Predictive Value阴性预测值 tn / (tn + fn)
ppv Positive Predictive Value阳性预测值 tp / (tp + fp) precision
precision Precision精准率 tp / (tp + fp) ppv
recall Recall正确率 tp / (tp + fn) sensitivity, tpr
tpr True Positive Rate真阳性率 tp / (tp + fn) sensitivity, recall
fpr False Positive Rate假阳性率 fp / (tn + fp) 1-specificity
tnr True Negative Rate真阴性率 tn / (tn + fp) specificity
fnr False Negative Rate假阴性率 fn / (tp + fn) 1-sensitivity
fdr False Discovery Rate伪发现率 fp / (tp + fp) 1-ppv

# 安装黑苹果

最近电脑老是蓝屏，很是恼人，怀疑是win10系统的原因，重装了好几次还是蓝屏，于是决定装个黑苹果，用macOS系统（装好黑苹果MacOS 10.15 Catalina之后，发现可能是硬盘的问题导致蓝屏的，pity）。总结一下过程，看教程的时候很麻烦，实操一遍之后，回顾一下，其实还是蛮简单的，大致过程和装windows一样，就是多了添加clover引导，方便黑苹果从硬盘引导而不是U盘。下面是总结了一下过程，不是详细，方便以后再装

# 1，设置好分区

此电脑-管理-磁盘管理

（1）确保格式为GPT格式（GUID）

（2）确保有EFI分区

（3）压缩卷，给空出来的卷新建卷，不要选择格式化这个卷（安装黑苹果的过程中会进行）

（4）这个新建的卷就是安装黑苹果的分区

# 2，制作 MacOS 安装盘

## （1）下载镜像

强烈推荐 “黑果小兵“ 的网站： https://blog.daliansky.net/

上面可以找OS的镜像，含有Clover引导

## （2）制作安装U盘

下载Transmac: https://transmac.en.softonic.com/

有15天的试用期

选择 format with disk image，选择下载的OS文件，等待完成

# 3，安装Mac OS

## （1）设置BIOS

不同的电脑的BIOS稍微不同，我看多数涉及下面这两个，其他的还需要自己搜下

比如SATA Operation 勾选 AHCI

Secure Boot Enable 勾选 Disable

## （2）设置BIOS为UEFI U盘启动

通过U盘进入Clover引导之后，选择安装Install macOS ，中间会重启一次，重启之后，选择Install macOS Mojave from “你设置的盘”

等待系统安装好

# 4，设置Clover引导

## （1）复制Clover文件夹

下载Mac版本的Clover configurator http://www.pc6.com/mac/294926.html，不拔安装U盘的情况下，在挂载分区的选项中把系统的ESP和U盘的ESP分区挂载上。

复制U盘ESP分区中的clover文件到到系统的ESP分区EFI文件夹下（和mircosoft同级）

## （2）利用bootice添加Clover引导

在原来的windows系统下，或者通过Win PE，利用Disk Genius普通版即可，https://www.diskgenius.cn/ ，把系统的ESP分配一个盘符

下载安装bootice之后，https://bootice.en.softonic.com/

Bootice-UEFI0修改启动序列-添加，在路径上，选择ESP下EFI/CLOVER/CLOVERX64.efi，名称可以自己设置成Clover Boot Manager（开机的时候就是显示这个）

# 5，大功告成

开机的时候选择不同的引导进入不同的系统，这样也实现了单硬盘双系统。

参考：

https://hackintosh.kirainmoe.com/an-zhuang-zhong/efi-ti-huan-jiao-cheng

https://blog.daliansky.net/macOS-Catalina-10.15.5-19F96-Release-version-with-Clover-5118-original-image-Double-EFI-Version-UEFI-and-MBR.html

https://blog.csdn.net/qq_28735663/article/details/99695786