将信息从矢量提取到另一个数据帧

时间:2015-12-07 14:13:23

标签: r

Mature_Hep中的数据与Recurrence中的数据相匹配。我想将Recurrence上的信息传递到matrix_cpm_spike_norm_mature_liver.m中的列,方法是将其与变量Var2相匹配。请参阅我的输出示例。

> colnames(Mature_Hep)
 [1] "Sa TxHep 092"   "Sa TxHep 112"   "Sa TxHep 121"   "Sa TxHep 164"   "Sb TxHep 014"   "Sc TxHep 018"   "Sb TxHep 082"  
 [8] "Sa TxHep 084"   "Sa MM-7"        "Sa TxHep 086"   "Sa TxHep 088"   "Sa TxHep 094"   "Sa TxHep 096"   "Sa TxHep 102"  
[15] "Sa TxHep 113"   "Sa TxHep 120"   "Sa TxHep 134"   "Sa Tx Hep 140 " "Sa TxHep 144"   "Sc D-10"        "Sa TxHep 145"  
[22] "Sa TxHep 146"   "Sa TxHep 157"   "Sc TxHep 158"   "Sa TxHep 161"   "Sa TxHep 176"   "Sc TxHep 185"   "Sa TxHep 186"  
[29] "Sc TxHep 192"   "Sa TxHep 201"   "Sa S-26"        "Sa TxHep 204"   "Sb TxHep 215"   "Sb TxHep 236"   "Sa CD-21"      
[36] "Sa MT-27"       "Sb MP-32"       "Sa GD-38"       "Sc CG-39"       "Sc-DG-45"       "Sc PC-46"       "Sa VS-29"      
[43] "Sb 1018"        "Sb 1065"        "Sb 1068"        "Sb 1104"        "Sd 1167"        "Sc 1196"        "Sb 1222"       
[50] "Sb 1237"        "Sb 1241"        "Sc 1302"        "Sa BF-33"       "Sb 1304"        "Sb 1322"        "Sc 1372"       
[57] "Sa 1474"        "Sc 1532"        "Sd 1540"        "Sb 1588"        "Sa 1604"        "Sc 1743"        "Sb 1808"       
[64] "Sc TxHep 015"   "Sa 1809"        "Sd 1859"        "Sb 1894"        "Sb 2218"        "Sb 2239"        "Sa HEP 014"    
[71] "Sb HEP 015"     "Sa HEP 018"     "Sb HEP 020"     "Sa TxHep 080"   "Sa HEP 045"     "Sa TxHep 090"   "Sa TxHep 091"  
> 

> Recurrence
 [1] Recurrence    No recurrence No recurrence No recurrence No recurrence No recurrence No recurrence No recurrence
 [9] Recurrence    No recurrence No recurrence No recurrence No recurrence No recurrence No recurrence No recurrence
[17] Recurrence    No recurrence No recurrence Recurrence    No recurrence No recurrence No recurrence No recurrence
[25] No recurrence No recurrence Recurrence    No recurrence No recurrence Recurrence    Recurrence    No recurrence
[33] No recurrence No recurrence No recurrence No recurrence No recurrence No recurrence No recurrence No recurrence
[41] No recurrence No recurrence Recurrence    Recurrence    Recurrence    No recurrence Recurrence    Recurrence   
[49] Recurrence    Recurrence    No recurrence No recurrence Recurrence    No recurrence Recurrence    No recurrence
[57] Recurrence    Recurrence    No recurrence Recurrence    No recurrence Recurrence    Recurrence    No recurrence
[65] No recurrence No recurrence Recurrence    Recurrence    No recurrence No recurrence No recurrence No recurrence
[73] No recurrence Recurrence    No recurrence No recurrence No recurrence
Levels: No recurrence Recurrence

> head(matrix_cpm_spike_norm_mature_liver.m)
            Var1         Var2    value
1  hsa-let-7a-5p Sa TxHep 092 12.60482
2  hsa-let-7b-5p Sa TxHep 092 10.89667
3  hsa-let-7f-5p Sa TxHep 092 13.50249
4  hsa-let-7g-5p Sa TxHep 092 10.55820
5  hsa-let-7i-5p Sa TxHep 092 12.03462
6 hsa-miR-101-3p Sa TxHep 092 10.37932

输出:

> head(matrix_cpm_spike_norm_mature_liver.m)
            Var1         Var2    value   Recurrence_Status
1  hsa-let-7a-5p Sa TxHep 092 12.60482   Recurrence
2  hsa-let-7b-5p Sa TxHep 092 10.89667   Recurrence
3  hsa-let-7f-5p Sa TxHep 092 13.50249   Recurrence
4  hsa-let-7g-5p Sa TxHep 092 10.55820   Recurrence
5  hsa-let-7i-5p Sa TxHep 092 12.03462   Recurrence
6 hsa-miR-101-3p Sa TxHep 092 10.37932   Recurrence

1 个答案:

答案 0 :(得分:1)

这有用吗?

public void CopyRecursive(string path, string newLocation)
{
    foreach(var file in DirectoryInfo.GetFiles(path))
    {
        File.Copy(file.FullName, newLocation + file.Name);
    }

    foreach(var dir in DirectoryInfo.GetDirectories(path))
    {
        CopyRecursive(path + dir.Name, newLocation);
    }
}

它提取与Recurrance ==“Recurrance”和Recurrence ==“No recurrance”相关联的字符串名称,并根据这些字符串的匹配在新矩阵中创建一个%in%的变量。