【问题标题】:How to load a sequence of elliptic Fourier coefficients into R to make an outline analysis in Momocs package?如何将一系列椭圆傅里叶系数加载到 R 中以在 Momocs 包中进行轮廓分析?
【发布时间】:2017-09-30 15:03:28
【问题描述】:

我是 R 新手。

我有一个带有预先计算的椭圆傅立叶系数(谐波)序列的文本文件。第一列保留对象名称,其他 - 谐波集除以空格:A0 B0 C0 D0 ... An Bn Cn Dn。它是文件的一部分:

Lceph-sp1-1    0    0,27    -1    0    -0,29    0,2    0,1    -0,05    0,15    0,1    0,07    0,02
Lceph-sp1-2    0    -0,36    1    0    -0,27    0,25    0,12    -0,09    -0,26    -0,03    -0,17    0
Lceph-sp1-3    0    0,25    -1    0    -0,29    0,19    0,09    -0,05    0,15    0,1    0,06    0,01
Lceph-sp1-4    0    -0,37    1    0    -0,27    0,26    0,09    -0,07    -0,19    -0,07    -0,12    -0,02

我使用 read.delim2 命令将文件加载到 R 中:

ef <- read.delim2( "filename", header=FALSE, sep="")

然后我想使用来自Momocs package的函数分析获得的数据,如calibrate_harmonicpowerplotPCA等。

为此,需要将加载的数据转换为 Coe(?) 或其他对象。 (我不知道是哪一个。)

如何在 Momocs R 包中准备加载的数据进行分析?

【问题讨论】:

    标签: r fourier-descriptors


    【解决方案1】:

    如果您在 R/Momocs 之外计算椭圆傅立叶系数,则必须将它们作为OutCoe 对象导入,如下所示:

    # we load Momocs and import your table.
    library(Momocs)
    
    #Here I use your data (using `text` but a path to your file will work by your side
    data <- read.table(dec=",", text="
    Lceph-sp1-1    0    0,27    -1    0    -0,29    0,2    0,1    -0,05    0,15    0,1    0,07    0,02
    Lceph-sp1-2    0    -0,36    1    0    -0,27    0,25    0,12    -0,09    -0,26    -0,03    -0,17    0
    Lceph-sp1-3    0    0,25    -1    0    -0,29    0,19    0,09    -0,05    0,15    0,1    0,06    0,01
    Lceph-sp1-4    0    -0,37    1    0    -0,27    0,26    0,09    -0,07    -0,19    -0,07    -0,12    -0,02")
    
    # we can extract the `$fac` cofactor/variates table with `lf_structure`
    fac <- lf_structure(data[, 1], names=c("ind", "sp", "id"), split="-")
    
    # then we simply pass all columns but the first, the `fac` 
    # and two others arguments `Momocs` cannot deduce `method` and `norm`
    # see ?Outcoe
    x <- OutCoe(coe=data[, -1], fac=fac, method="efourier", norm=TRUE)
    

    我们现在有一个“工作”Outcoe 对象:

    > x
    An OutCoe object [ elliptical Fourier analysis ]
    --------------------
      - $coe: 4 outlines described, 3 harmonics
    - $fac: 3 classifiers:
      'ind' (factor 1): Lceph.
    'sp' (factor 1): sp1.
    'id' (factor 4): 1, 2, 3, 4.
    

    你可以用来继续你的分析,例如:

    x %>% PCA %>% plot
    

    这就是你要找的吗?

    【讨论】:

    • 抱歉耽搁了,以前没见过。
    猜你喜欢
    • 1970-01-01
    • 2020-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多