Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从R中的频率矩阵创建genet类_R_Data Analysis - Fatal编程技术网

从R中的频率矩阵创建genet类

从R中的频率矩阵创建genet类,r,data-analysis,R,Data Analysis,我尝试使用freq2genet方法在R中创建一个带有adegenet包的genet类。但一旦我用存储基因频率的数据集调用该方法,就会出现一个错误,即“类型”字符参数不正确。在我使用as.data.frame之后,它仍然会出现 如何解决这个问题?传递给freq2genet的对象应该是data.frame,其中行是观察总体,列是等位基因频率。这是ade4示例中的数据结构:::chevaine。任何与此不同的地方都可能是您出错的原因 > head(chevaine$tab) PGM-2*

我尝试使用freq2genet方法在R中创建一个带有adegenet包的genet类。但一旦我用存储基因频率的数据集调用该方法,就会出现一个错误,即“类型”字符参数不正确。在我使用as.data.frame之后,它仍然会出现

如何解决这个问题?

传递给freq2genet的对象应该是data.frame,其中行是观察总体,列是等位基因频率。这是ade4示例中的数据结构:::chevaine。任何与此不同的地方都可能是您出错的原因

> head(chevaine$tab)
    PGM-2*.090 PGM-2*.098 PGM-2*.100 IDHP-1*.100 IDHP-1*.145 EST-2*.098 EST-2*.100 G3PDH*.085 G3PDH*.100
P01      0.017      0.150      0.833       1.000       0.000      0.300      0.700      0.217      0.783
P02      0.083      0.216      0.701       1.000       0.000      0.300      0.700      0.167      0.833
P03      0.107      0.179      0.714       0.982       0.018      0.250      0.750      0.179      0.821
P04      0.067      0.200      0.733       1.000       0.000      0.467      0.533      0.217      0.783
P05      0.103      0.190      0.707       1.000       0.000      0.362      0.638      0.103      0.897
P06      0.179      0.125      0.696       0.981       0.019      0.250      0.750      0.154      0.846

> str(freq2genet(chevaine$tab))
List of 8
 $ tab       :'data.frame': 27 obs. of  9 variables:
  ..$ L1.1: num [1:27] 0.3 0.3 0.25 0.467 0.362 0.25 0.217 0.308 0.25 0.31 ...
  ..$ L1.2: num [1:27] 0.7 0.7 0.75 0.533 0.638 0.75 0.783 0.692 0.75 0.69 ...
  ..$ L2.1: num [1:27] 0.217 0.167 0.179 0.217 0.103 0.154 0.1 0.038 0.05 0.119 ...
  ..$ L2.2: num [1:27] 0.783 0.833 0.821 0.783 0.897 0.846 0.9 0.962 0.95 0.881 ...
  ..$ L3.1: num [1:27] 1 1 0.982 1 1 0.981 0.983 1 0.975 0.976 ...
  ..$ L3.2: num [1:27] 0 0 0.018 0 0 0.019 0.017 0 0.025 0.024 ...
  ..$ L4.1: num [1:27] 0.017 0.083 0.107 0.067 0.103 0.179 0.216 0.25 0.175 0.282 ...
  ..$ L4.2: num [1:27] 0.15 0.216 0.179 0.2 0.19 0.125 0.2 0.115 0.05 0 ...
  ..$ L4.3: num [1:27] 0.833 0.701 0.714 0.733 0.707 0.696 0.584 0.635 0.775 0.718 ...
 $ center    : Named num [1:9] 0.322 0.678 0.114 0.886 0.901 ...
  ..- attr(*, "names")= chr [1:9] "L1.1" "L1.2" "L2.1" "L2.2" ...
 $ pop.names : Named chr [1:27] "P01" "P02" "P03" "P04" ...
  ..- attr(*, "names")= chr [1:27] "P01" "P02" "P03" "P04" ...
 $ all.names : Named chr [1:9] "EST-2*.098" "EST-2*.100" "G3PDH*.085" "G3PDH*.100" ...
  ..- attr(*, "names")= chr [1:9] "L1.1" "L1.2" "L2.1" "L2.2" ...
 $ loc.blocks: Named num [1:4] 2 2 2 3
  ..- attr(*, "names")= chr [1:4] "L1" "L2" "L3" "L4"
 $ loc.fac   : Factor w/ 4 levels "EST-2*","G3PDH*",..: 1 1 2 2 3 3 4 4 4
 $ loc.names : Named chr [1:4] "EST-2*" "G3PDH*" "IDHP-1*" "PGM-2*"
  ..- attr(*, "names")= chr [1:4] "L1" "L2" "L3" "L4"
 $ all.pop   :'data.frame': 9 obs. of  27 variables:
  ..$ P01: num [1:9] 0.3 0.7 0.217 0.783 1 0 0.017 0.15 0.833
  ..$ P02: num [1:9] 0.3 0.7 0.167 0.833 1 0 0.083 0.216 0.701
  ..$ P03: num [1:9] 0.25 0.75 0.179 0.821 0.982 0.018 0.107 0.179 0.714
  ..$ P04: num [1:9] 0.467 0.533 0.217 0.783 1 0 0.067 0.2 0.733
  ..$ P05: num [1:9] 0.362 0.638 0.103 0.897 1 0 0.103 0.19 0.707
  ..$ P06: num [1:9] 0.25 0.75 0.154 0.846 0.981 0.019 0.179 0.125 0.696
  ..$ P07: num [1:9] 0.217 0.783 0.1 0.9 0.983 0.017 0.216 0.2 0.584
  ..$ P08: num [1:9] 0.308 0.692 0.038 0.962 1 0 0.25 0.115 0.635
  ..$ P09: num [1:9] 0.25 0.75 0.05 0.95 0.975 0.025 0.175 0.05 0.775
  ..$ P10: num [1:9] 0.31 0.69 0.119 0.881 0.976 0.024 0.282 0 0.718
  ..$ P11: num [1:9] 0.308 0.692 0.154 0.846 0.962 0.038 0.154 0.038 0.808
  ..$ P12: num [1:9] 0.354 0.646 0.104 0.896 0.979 0.021 0.125 0.104 0.771
  ..$ P13: num [1:9] 0.317 0.683 0.167 0.833 0.8 0.2 0.033 0.716 0.251
  ..$ P14: num [1:9] 0.3 0.7 0.083 0.917 0.75 0.25 0.033 0.6 0.367
  ..$ P15: num [1:9] 0.46 0.54 0.14 0.86 0.74 0.26 0.04 0.62 0.34
  ..$ P16: num [1:9] 0.369 0.631 0.119 0.881 0.69 0.31 0 0.69 0.31
  ..$ P17: num [1:9] 0.494 0.506 0.104 0.896 0.747 0.253 0.003 0.659 0.338
  ..$ P18: num [1:9] 0.321 0.679 0.036 0.964 0.589 0.411 0 0.536 0.464
  ..$ P19: num [1:9] 0.286 0.714 0.086 0.914 0.871 0.129 0.129 0.343 0.528
  ..$ P20: num [1:9] 0.267 0.733 0.05 0.95 0.95 0.05 0.15 0.133 0.717
  ..$ P21: num [1:9] 0.241 0.759 0.121 0.879 0.966 0.034 0.138 0.103 0.759
  ..$ P22: num [1:9] 0.25 0.75 0.162 0.838 0.941 0.059 0.176 0.059 0.765
  ..$ P23: num [1:9] 0.339 0.661 0.054 0.946 0.893 0.107 0.125 0.089 0.786
  ..$ P24: num [1:9] 0.386 0.614 0.068 0.932 0.886 0.114 0.114 0.136 0.75
  ..$ P25: num [1:9] 0.308 0.692 0.115 0.885 0.823 0.177 0.135 0.01 0.855
  ..$ P26: num [1:9] 0.338 0.662 0.103 0.897 0.912 0.088 0.088 0.103 0.809
  ..$ P27: num [1:9] 0.353 0.647 0.074 0.926 0.941 0.059 0.059 0.118 0.823
 - attr(*, "class")= chr [1:2] "genet" "list"

您需要更改数据的格式,而不是数据的类型。也许将参数从字符改为逻辑就可以了。你在手册上查过了吗?你的数据与freq2genet示例或任何其他工作示例有何区别?@Llopis如何做到这一点?@RomanLuštrik freq2genet没有可参考的示例…在这一点上,我将要求提供一个可复制的示例。到目前为止,我仍然不知道错误在哪里1.我找不到我的工作和上面的例子之间的区别。看起来很相似,但我的数据集。我的数据集是从csv文件中读取的,并经过一些处理。它包含相对较小的频率,如0。我无法使用freq2genet处理数据。正如我在问题中所说,出现了一个错误。。