【发布时间】:2021-10-08 09:20:33
【问题描述】:
我有两个文件,dat(samp.matrix是它的数据矩阵)和它对应的注解文件ann。我删除了samp.matrix 中的异常值,现在想通过删除相应的异常值来更新ann(如ann.filtered)。如何更新ann?
samp.matrix <- data.matrix(dat[, (3:ncol(dat))])
# Remove Outlier(s)
samp.matrix <- samp.matrix[, -(grep(names(outlier), colnames(samp.matrix)))]
# Eliminating probes with rowMeans less than 0 on a log2 scale
dat.fil <- subset(samp.matrix, log2(rowMeans(samp.matrix)) > 0)
removed <- nrow(samp.matrix) - nrow(dat.fil)
# Eliminate probes with rowMeans less than 3 on a log2 scale
dat.filtered <- subset(dat.fil, rowMeans(dat.fil) > 3)
dat.filtered <- as.data.frame(dat.filtered)
removed <- nrow(dat.fil) - nrow(dat.filtered)
# Update annotation file
ID_REF <- rownames(ann)
ann <- cbind(ID_REF, ann)
rownames(ann) <- NULL
ann <- ann %>% as.data.table()
dat.filtered <- dat.filtered %>% as.data.table()
ann.filtered <- ann[dat.filtered, on=.("ID_REF")] %>%
select(ID_REF, Gene.title, Gene.symbol)
colnamesInt(i, unname(on), check_dups = FALSE) 中的错误:参数 指定列指定不存在的列:cols[1]='ID_REF'
dat
| ID_REF | IDENTIFIER | GSM97800 | GSM97804 |
|---|---|---|---|
| 1007_s_at | MIR4640 | 4701.5 | 4735.0 |
| 1053_at | RFC2 | 282.7 | 347.9 |
| 117_at | HSPA6 | 769.6 | 287.9 |
| 121_at | PAX8 | 1616.3 | 1527.2 |
dat.filtered
| ID_REF | IDENTIFIER | GSM97800 | GSM97804 |
|---|---|---|---|
| 1007_s_at | MIR4640 | 4701.5 | 4735.0 |
| 1053_at | RFC2 | 282.7 | 347.9 |
ann
| ID_REF | Gene.title | Gene.symbol | Gene.ID |
|---|---|---|---|
| 1007_s_at | microRNA 4640//discoidin domain receptor | MIR4640//DDR1 | 100616 |
| 1053_at | replication factor C subunit 2 | RFC2 | 5982 |
| 117_at | heat shock protein family A (Hsp70) | HSPA6 | 3310 |
| 121_at | paired box 8 | PAX8 | 7849 |
预期输出
ann.filtered
| ID_REF | Gene.title | Gene.symbol | Gene.ID |
|---|---|---|---|
| 1007_s_at | microRNA 4640//discoidin domain receptor | MIR4640//DDR1 | 100616 |
| 1053_at | replication factor C subunit 2 | RFC2 | 5982 |
【问题讨论】:
标签: r dataframe filter statistics