I have a file with cluster number of a scRNA-seq and corresponding annotated cell type like
> dput(head(anno))
structure(list(cluster = 1:6, celltype = c("T:CD4+NAIVE", "T:CD4+NAIVE",
"T:CD8+NAIVE", "NK:CD56+16+3+NKT", "T:CD8+NAIVE", "B:")), row.names = c(NA,
6L), class = "data.frame")
> unique(anno$cluster)
[1] 1 2 3 4 5 6 8 9 11 12 15 16 19 20 21 22 23 24 25 27 28 29 30 31 35 36 37 38 39 40 41 42 43 44 45 46
[37] 47 48 49 50 51 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 81 82 83 84
[73] 85 86 87 88 89 90 91 92 93 94 95
> unique(anno$celltype)
[1] "T:CD4+NAIVE" "T:CD8+NAIVE" "NK:CD56+16+3+NKT" "B:" "NKT"
[6] "T:CD8+EM" "T:CD4+CM" "mDC:" "MACROPHAGE:" "MONOCYTE:precursor"
[11] "NEUTROPHIL:" "NK:CD56+16+3-" "MAST:" "MONOCYTE:" "pDC:"
[16] "T:Reg"
and another data frame with cell IDs and corresponding cluster number of each cell
> dput(head(df2))
structure(list(cluster = c(1L, 1L, 1L, 1L, 1L, 1L), cellid = c("cell17203",
"cell17205", "cell17206", "cell17207", "cell17208", "cell17209"
)), row.names = 15498:15503, class = "data.frame")
> unique(df2$cluster)
[1] 1 2 3 4 5 6 8 12 16 19 21 23 27 29 30 35 36 40 53 55 92 11 24 38 41 46 90 9 15 20 47 74 57 39 42 25
[37] 56 64
>
> dim(df2)
[1] 16056 2
>
I want to create a cell type column in the second data frame (df2) in which relate cell type from the first data frame to cluster number for instance cluster 1
is T:CD4+NAIVE
I have tried these
> df2[anno, on = "cluster"]
Error in `[.data.frame`(df2, anno, on = "cluster") :
unused argument (on = "cluster")
> df2[c, on = anno$cluster]
Error in `[.data.frame`(df2, anno, on = c$cluster) :
unused argument (on = anno$cluster)
> df2[c, on = df2$cluster]
Error in `[.data.frame`(df2, anno, on = df2$cluster) :
unused argument (on = df2$cluster)