Skip to content

Commit

Permalink
add ReadParseBio
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewwbutler committed Jul 15, 2021
1 parent 7c9a047 commit a1cc5ea
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 5 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export(Read10X)
export(Read10X_Image)
export(Read10X_h5)
export(ReadMtx)
export(ReadParseBio)
export(ReadSTARsolo)
export(ReadSlideSeq)
export(Reductions)
Expand Down
29 changes: 27 additions & 2 deletions R/convenience.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,41 @@ SpecificDimPlot <- function(object, ...) {
)
}

#' Read output from Parse Biosciences
#'
#' @param data.dir Directory containing the data files
#' @param ... Extra parameters passed to \code{\link{ReadMtx}}
#' @concept convenience
#' @export
#'
ReadParseBio <- function(data.dir, ...) {
mtx <- file.path(data.dir, "DGE.mtx")
cells <- file.path(data.dir, "cell_metadata.csv")
features <- file.path(data.dir, "genes.csv")
return(ReadMtx(
mtx = mtx,
cells = cells,
features = features,
cell.column = 1,
feature.column = 2,
cell.sep = ",",
feature.sep = ",",
skip.cell = 1,
skip.feature = 1,
mtx.transpose = TRUE
))
}

#' Read output from STARsolo
#'
#' @param data.dir Directory containing the data files
#' @param ... Extra parameters passed to \code{ReadMtx}
#' @param ... Extra parameters passed to \code{\link{ReadMtx}}
#'
#' @rdname ReadSTARsolo
#' @concept convenience
#' @export
#'
ReadSTARsolo <- function(data.dir, ... ){
ReadSTARsolo <- function(data.dir, ... ) {
mtx <- file.path(data.dir, "matrix.mtx")
cells <- file.path(data.dir, "barcodes.tsv")
features <- file.path(data.dir, "features.tsv")
Expand Down
13 changes: 11 additions & 2 deletions R/preprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,11 @@ Read10X_Image <- function(image.dir, image.name = "tissue_lowres_image.png", fil
#' @param features Name or remote URL of the features/genes file
#' @param cell.column Specify which column of cells file to use for cell names; default is 1
#' @param feature.column Specify which column of features files to use for feature/gene names; default is 2
#' @param cell.sep Specify the delimiter in the cell name file
#' @param feature.sep Specify the delimiter in the feature name file
#' @param skip.cell Number of lines to skip in the cells file before beginning to read cell names
#' @param skip.feature Number of lines to skip in the features file before beginning to gene names
#' @param mtx.transpose Transpose the matrix after reading in
#' @param unique.features Make feature names unique (default TRUE)
#' @param strip.suffix Remove trailing "-1" if present in all cell barcodes.
#'
Expand Down Expand Up @@ -1085,8 +1088,11 @@ ReadMtx <- function(
features,
cell.column = 1,
feature.column = 2,
cell.sep = "\t",
feature.sep = "\t",
skip.cell = 0,
skip.feature = 0,
mtx.transpose = FALSE,
unique.features = TRUE,
strip.suffix = FALSE
) {
Expand Down Expand Up @@ -1118,14 +1124,14 @@ ReadMtx <- function(
cell.barcodes <- read.table(
file = all.files[['barcode list']],
header = FALSE,
sep = '\t',
sep = cell.sep,
row.names = NULL,
skip = skip.cell
)
feature.names <- read.table(
file = all.files[['feature list']],
header = FALSE,
sep = '\t',
sep = feature.sep,
row.names = NULL,
skip = skip.feature
)
Expand Down Expand Up @@ -1196,6 +1202,9 @@ ReadMtx <- function(
feature.names <- make.unique(names = feature.names)
}
data <- readMM(file = all.files[['expression matrix']])
if (mtx.transpose) {
data <- t(x = data)
}
if (length(x = cell.names) != ncol(x = data)) {
stop(
"Matrix has ",
Expand Down
9 changes: 9 additions & 0 deletions man/ReadMtx.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions man/ReadParseBio.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/ReadSTARsolo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a1cc5ea

Please sign in to comment.