An example solution for Seurat:
Retrieve sample IDs from the .csv used with cellranger:
samples <- read.csv(file.path("/path/to/csv", "nameof.csv"), stringsAsFactors=F)
Load the 10x dataset and initialize the Seurat object:
cells.data <- Read10X("path/to/filtered_gene_bc_matrices")
cells <- new("seurat", raw.data=cells.data)
Get barcodes and suffix:
cellcodes <- as.data.frame(cells@raw.data@Dimnames[[2]])
colnames(cellcodes) <- "barcodes"
rownames(cellcodes) <- cellcodes$barcodes
cellcodes$libcodes <- as.factor(gsub(pattern=".+-", replacement="", cellcodes$barcodes))
cellcodes$samples <- as.vector(samples$library_id[cellcodes$libcodes])
Create dataframe for meta.data argument and set up object:
sampleidentity <- cellcodes["samples"]
cells <- Setup(cells,
meta.data=sampleidentity,
min.cells=3,
min.genes=200,
do.logNormalize=T, total.expr=1e4, project="projectname")
Use the group.by argument of various functions.
MergeSeurat()andAddSamples()functions. See this question and seurat vignette – Peter Aug 22 '17 at 10:48