1.可以直接在Microsoft store中下载ubuntu
,如果没有使用过打开是这样的
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x8007019e
Error: 0x8007019e ??????? Linux ? Windows ????
Press any key to continue...
2.控制面板里打开这三个
参照官网进行安装
下载并安装
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
terminal运行
wsl --set-default-version 2
关闭终端
打开ubuntu
设置账号密码 /密码输入的时候是不显示的
进入linux
——————————————
miniconda 搭建虚拟环境
——————————————
4.PopLDdecay安装
sudo apt update
# 安装 build-essential 包(包含 gcc、g++ 和 make)
sudo apt install build-essential
sudo apt install zlib1g-dev
#安装PopLDdecay
git clone https://github.com/BGI-shenzhen/PopLDdecay.git
cd PopLDdecay
chmod 755 configure
./configure
make
mv PopLDdecay ./bin/
# 打开 .bashrc 文件
nano ~/.bashrc
# 在文件末尾添加以下行(使用您的实际路径)
export PATH="/mnt/f/linux_zky/PopLDdecay-master/bin:$PATH"
# 保存并退出 nano(按 Ctrl+X,然后 Y,最后 Enter)
# 使更改生效
source ~/.bashrc
# 验证 PATH 更新
echo $PATH
环境变量配置成功
5.使用PopLDdecay计算
PopLDdecay -InVCF /mnt/e/pyProjects/zc/2024年8月23日/ZC-wanglin分析/data/clean.vcf -OutStat LDdecay
当前路径下生成结果文件 LDdecay.stat.gz
安装R
安装Rstudio
参数没搞懂怎么设置
反正能跑
先计算出ld.stat
PopLDdecay -InVCF clean.vcf -MaxDist 5000 -OutStat ld.stat
可以用自带的工具直接出图
../PopLDdecay-master/bin/Plot_OnePop.pl -inFile /mnt/f/linux_zky/zc_LD/ld.stat.gz --output re1 -bin1 10 -bin2 100
也可以用R自己做
# 清除工作环境中的变量
rm(list = ls())
# 设置工作目录
setwd("E:/pyProjects/zc/2024年8月23日")
# 加载必要的库
library(ggplot2)
library(dplyr)
# 读取数据并设置正确的列名
ld_data <- read.table("F:/linux_zky/zc_LD/ld.stat", header = TRUE, sep = "\t") %>%
setNames(c("Distance", "r2", "NA1", "r2_mean", "NA2", "Count"))
# 参数设置
bin1 <- 10
bin2 <- 100
break_point <- 1000
# 数据处理函数
process_data <- function(data, bin_size, break_point) {
data %>%
mutate(bin = ifelse(Distance < break_point,
floor((Distance - 0.1) / bin_size) * bin_size,
floor((Distance - 0.1) / bin_size) * bin_size + break_point)) %>%
group_by(bin) %>%
summarise(mean_r2 = mean(r2, na.rm = TRUE),
count = sum(Count)) %>%
arrange(bin)
}
# 处理数据
small_bins <- process_data(filter(ld_data, Distance < break_point), bin1, break_point)
large_bins <- process_data(filter(ld_data, Distance >= break_point), bin2, break_point)
# 合并数据
combined_data <- bind_rows(small_bins, large_bins) %>% arrange(bin)
# 创建LD衰减图(热图风格和平滑处理,减少 x 轴密度)
ld_plot <- ggplot(combined_data, aes(x = bin, y = mean_r2)) +
geom_point(aes(color = bin), alpha = 0.5, size = 1) +
geom_smooth(method = "loess", color = "black", se = FALSE, size = 1) +
scale_color_gradient(low = "blue", high = "red") +
scale_x_continuous(
breaks = seq(0, max(combined_data$bin), by = 200000), # 增加间隔到 200,000
labels = function(x) paste0(x/1000000, "Mb"),
expand = c(0.01, 0) # 稍微扩展 x 轴以避免点被切off
) +
scale_y_continuous(limits = c(0, 1)) +
theme_minimal() +
theme(
legend.position = "right",
plot.title = element_text(face = "bold", size = 14, hjust = 0.5),
axis.title = element_text(size = 12),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 1), # 旋转 x 轴标签以避免重叠
plot.margin = margin(5.5, 14, 5.5, 14)
) +
labs(
title = "LD Decay Plot (Smoothed)",
x = "Distance (Kb)",
y = expression(r^2),
color = "Distance (Mb)"
)
# 保存图形
ggsave("LD_decay_plot_smoothed_heatmap_reduced_density.png", ld_plot, width = 12, height = 6, dpi = 300)