如何根据其他数据框中最近的邻居编辑列

时间:2016-06-07 15:22:10

标签: r bioinformatics bioconductor

如何将df1(开始和结束列)的边界移动到标记文件中最接近的位置列。我想将df1的开始和结束列调整为在标记提供的染色体列应匹配的最近匹配。

x <- "Sample    Chromosome  Start   End     Num_markers LogRatio
       Samp.1        6  14170000.5  26930000.5  309     0.393 
       Samp.1        7  50000.5     57690000.5  1411    -0.0486       
       Samp.1        13 19250000.5  83370000.5  1586    -0.5121"

df1 <-read.table(text=x, header=T, sep = "\t")



marK <- "Name   Chromosome  Position
7:50000.5       7   50000.5
7:57670000.5    7   57670000.5
6:14170000.5    6   14170000.5
6:26950000.5    6   26950000.5
6:36950000.5    6   36950000.5
13:19270000.5   13  19270000.5
13:83370000.5    13   83370000.5" 
marker <- read.table(text=marK, header=T)


expectedOutput <- "Sample  Chromosome  Start    End   Num_markers LogRatio
                    Samp.1   6     14170000.5   26950000.5  309   0.393    
                    Samp.1   7       50000.5    57670000.5  1411 -0.0486
                    Samp.1  13      19270000.5  83370000.5  1586    -0.5121"

0 个答案:

没有答案