首页 > 解决方案 > 如何在 ade4 中使用与 sPCA 包相同的包 adespatial

问题描述

我使用带有函数 sPCA 的包 adegenet 来了解我的遗传数据中是否存在地理模式。

vcf<- read.table("AMZ.012") #samples per line
vcf_m<-as.matrix(vcf)

# Add coordinates of samples
xy <-read.table("CoordAMZ_m.csv", sep=",") #geo coordinates for each sample

矩阵“vcf”有 0 和 1(1 表示有信息,0 表示没有信息),每行是不同的样本,如下例所示:

0 1 0 1
1 1 0 1
1 1 0 0

我按照示例在 R 中使用 adgenet 包运行了 sPCA:

mySpca <- spca(vcf_m, xy, ask=FALSE, type=5, scannf=FALSE)

结果是:

This function is now deprecated. Please use the 'multispati' function in the 'adespatial' package. 

我尝试使用这个新功能,但我不知道如何使用与在 sPCA 中实现的功能相同的功能并获得类似的结果。我期待这个 pdf ( http://adegenet.r-forge.r-project.org/files/tutorial-spca.pdf ) 第 7 页中的内容。

如果有人可以帮助我,我会非常高兴。

谢谢。

标签: r

解决方案


我不确定您是否仍然感兴趣,但这很简单。首先看一下,args(multispati)看看需要什么。

dudi所需的第一个参数是在ade4包中使用的多变量排序分析。

我创建了一个dudi.pca.

然后listw需要一个。

这只是一个加权连接网络,类似于您在 sPCA 中使用的,但格式不同。

您可以chooseCN像在您的 sPCA 中一样使用。

然后使用该功能将您转换myCN为 a 。listwnb2listw

希望这可以帮助!

干杯,凯特


推荐阅读