我有一个名为matrix_cpm_spike_norm_mature_liver.Survival.m
的融合矩阵。我想根据Survival
向量中的信息添加名为Survival
的新列。 Survival
向量与Mature_Hep
匹配,再次与融合矩阵中variable
中的 > head(matrix_cpm_spike_norm_mature_liver.Survival.m)
miRNA variable value
1 hsa-miR-101-3p Sa TxHep 092 10.315108
2 hsa-miR-10a-5p Sa TxHep 092 11.803228
3 hsa-miR-141-3p Sa TxHep 092 4.507543
4 hsa-miR-146b-5p Sa TxHep 092 6.890910
5 hsa-miR-148a-3p Sa TxHep 092 12.615621
6 hsa-miR-192-5p Sa TxHep 092 11.058548
> Survival
[1] Dead Alive Alive Alive Dead Dead Alive Alive Dead Alive Alive Alive Alive Dead Alive Alive Dead Alive Alive
[20] Alive Alive Alive Alive Alive Alive Alive Alive Alive Alive Dead Dead Alive Dead Alive Alive Dead Alive Alive
[39] Alive Alive Alive Alive Alive Dead Dead Dead Dead Alive Dead Dead Dead Dead Dead Dead Dead Alive Dead
[58] Alive Dead Dead Alive Dead Dead Alive Dead Alive Dead Alive Dead Dead Alive Alive Alive Alive Alive Dead
[77] Alive Alive Dead
Levels: Alive Dead
> colnames(Mature_Hep)
[1] "Sa TxHep 092" "Sa TxHep 112" "Sa TxHep 121" "Sa TxHep 164" "Sb TxHep 008" "Sc TxHep 008" "Sb TxHep 014"
[8] "Sc TxHep 018" "Sb TxHep 082" "Sa TxHep 084" "Sa MM-7" "Sa TxHep 086" "Sa TxHep 088" "Sa TxHep 094"
[15] "Sa TxHep 096" "Sa TxHep 102" "Sa TxHep 113" "Sa TxHep 120" "Sa TxHep 134" "Sa Tx Hep 140 " "Sa TxHep 144"
[22] "Sc D-10" "Sa TxHep 145" "Sa TxHep 146" "Sa TxHep 157" "Sc TxHep 158" "Sa TxHep 161" "Sa TxHep 176"
[29] "Sc TxHep 185" "Sa TxHep 186" "Sc TxHep 192" "Sa TxHep 201" "Sa S-26" "Sa TxHep 204" "Sb TxHep 215"
[36] "Sb TxHep 236" "Sa CD-21" "Sa MT-27" "Sb MP-32" "Sa GD-38" "Sc CG-39" "Sc-DG-45"
[43] "Sc PC-46" "Sa VS-29" "Sb 1018" "Sb 1065" "Sb 1068" "Sb 1104" "Sd 1167"
[50] "Sc 1196" "Sb 1222" "Sb 1237" "Sb 1241" "Sc 1302" "Sa BF-33" "Sb 1304"
[57] "Sb 1322" "Sc 1372" "Sa 1474" "Sc 1532" "Sd 1540" "Sb 1588" "Sa 1604"
[64] "Sc 1743" "Sb 1808" "Sc TxHep 015" "Sa 1809" "Sd 1859" "Sb 1894" "Sb 2218"
[71] "Sb 2239" "Sa HEP 014" "Sb HEP 015" "Sa HEP 018" "Sb HEP 020" "Sa TxHep 080" "Sa HEP 045"
[78] "Sa TxHep 090" "Sa TxHep 091"
相同。请参阅输出示例
miRNA variable value Survival
1 hsa-miR-101-3p Sa TxHep 092 10.315108 Dead
2 hsa-miR-10a-5p Sa TxHep 092 11.803228 Dead
3 hsa-miR-141-3p Sa TxHep 092 4.507543 Dead
4 hsa-miR-146b-5p Sa TxHep 092 6.890910 Dead
5 hsa-miR-148a-3p Sa TxHep 092 12.615621 Dead
6 hsa-miR-192-5p Sa TxHep 092 11.058548 Dead
输出:
function filterMainViz(filterName, values) {
var sheet = mainViz.getWorkbook().getActiveSheet();
var updateType;
if($('#'+values).is(":checked")) {
updateType = "ADD";
} else {
updateType = "REMOVE";
}
worksheetArray = sheet.getWorksheets();
for (var i = 0; i < worksheetArray.length; i++) {
worksheetArray[i].applyFilterAsync(filterName, values, updateType);
}
}
答案 0 :(得分:1)
将矩阵转换为数据框并执行merge():
Survival <- c("Dead","Alive","Alive","Alive")
Mature_Hep <- c("Sa TxHep 092","Sa TxHep 112","Sa TxHep 121","Sa TxHep 164")
df <- as.data.frame(Survival)
df <- cbind(df,Mature_Hep)
miRNA <- c("hsa-miR-101-3p","hsa-miR-10a-5p")
variable <- c("Sa TxHep 092","Sa TxHep 112")
df1 <- as.data.frame(miRNA)
df1 <- cbind(df1,variable)
result <- merge(df1,df,by.x = c("variable"),by.y = c("Mature_Hep"))