这是一个从22万多个基因突变里,挑选相邻100bp以内的基因突变对的代码
for(chromos in unique(maflength$Chromosome)){
for(samps in unique(maflength$Tumor_Sample_Barcode)){
maf <- maflength[maflength$Chromosome == chromos&
maflength$Tumor_Sample_Barcode == samps, ]
if(nrow(maf) >= 2){
for(i in 1:(nrow(maf)-1)){
j = i +1
while(j <= nrow(maf)){
if(all(!is.na(maf$Start_Position[j]), !is.na(maf$Start_Position[i]))&abs(maf$Start_Position[j] - maf$Start_Position[i]) <= 100){
GenDist <- data.frame(Mut1 = maf$Hugo_Symbol[i],
Mut1StarPos = maf$Start_Position[i],
Mut1EndPos = maf$End_Position[i],
Mut2 = maf$Hugo_Symbol[j],
Mut2StarPos = maf$Start_Position[j],
Mut2EndPos = maf$End_Position[j],
Chromosome = chromos,
SampleBarCode = samps)
Gens <- rbind(Gens, GenDist)
j <- j + 1
}
else break
}
}
}
else break
}
}
网友评论