0

我是这个 R 编程的新手,我在使用 R 编程语言获取 Affy 探针 ID 的基因名称和符号时遇到问题。

  • 探头符号名称
  • 215535_s_at 不适用 不适用
  • 32836_at 不适用 不适用
  • 210678_s_at 不适用 不适用
  • 32837_at 不适用
  • 219723_x_at 不适用 不适用
  • 223182_s_at NA NA 但我无法从合并 HGNC 和 David 平面文件中提取详细信息。

请让我知道如何最好地解决这个问题。

我使用了以下代码

enter code here
probe <- read.delim("super.txt",stringsAsFactors=F, header = T, sep="\t")
probe$probeid<-tolower(probe$probeid)
names<-read.delim("GSE42568_probeid.txt", as.is=T, stringsAsFactors=F, header=T)
##insted of dataframa we are sending out the vecotr
names<-names$probeid

NoMatchID = NULL
vec<-NULL
system.time({
for (i in 1:11390){
  index<-grep(names[i],probe$probeid,fixed=T)
  #index<-grep(paste("^",names[i],"$"),probe$probeid,fixed=T)
  if (length(index)!=0) {
    cat("Index of", names[i],"is", index, "\n")
  } else {
    cat("Index of", names[i], "Found No Match \n")
    NoMatchID = c(NoMatchID,i)
  }
NoMatchID<-c(NoMatchID,index)
vec_NA <- data.frame(probe[-NoMatchID,])
}
})
NoMatchID <- data.frame(probe[NoMatchID,]) 

NoMatchID_probe = setdiff(1:nrow(probe), unique(vec))
write.table(vec_NA, file = "probeids_matched_1.txt", row.names = FALSE, append =     FALSE, col.names = TRUE, sep = "\t")

如果你们有任何其他方法可以解决这个问题,请告诉我:(..这对我有很大帮助!!!

4

1 回答 1

0

我不确定你问什么。如果您的基因名称和符号在您的探针数据框中

probe <- read.delim("super.txt",stringsAsFactors=F, header = T, sep="\t")
probe$probeid<-tolower(probe$probeid)
names<-read.delim("GSE42568_probeid.txt", as.is=T, stringsAsFactors=F, header=T)
##insted of dataframa we are sending out the vecotr
names<-names$probeid

并且您想提取那些与您的向量probe不匹配的行的名称。names然后你应该修改你的代码如下:

#  NoMatchID = NULL
MatchID_probe <- NULL

for (i in 1:11390){
  index<-grep(names[i],probe$probeid,fixed=T)
  if (length(index)!=0) {
    cat("Index of", names[i],"is", index, "\n")
    MatchID_probe = c(MatchID_probe,index)
  } else {
    cat("Index of", names[i], "Found No Match \n")
    # NoMatchID = c(NoMatchID,i)
  }
}

NoMatchID_probe = setdiff(1:nrow(probe), unique(MatchID_probe))
DF_NoMatch <- probe[NoMatchID_probe,] 

DF_NoMatch
于 2014-09-15T14:08:36.993 回答