R/AllGenerics.R, R/method-BarcodeObj.R
bc_subset.RdA set of functions and operators for subsetting or joining of
BarcodeObj object(s).
The bc_subset, * and - are used to select barcodes or
samples in a BarcodeObj object.
Two BarcodeObj objects can be joined by +.
bc_subset(
barcodeObj,
sample = NULL,
barcode = NULL,
black_list = NULL,
is_sample_quoted_exp = FALSE
)
bc_merge(barcodeObj_x, barcodeObj_y)
# S4 method for class 'BarcodeObj'
bc_subset(
barcodeObj,
sample = NULL,
barcode = NULL,
black_list = NULL,
is_sample_quoted_exp = FALSE
)
# S4 method for class 'BarcodeObj,BarcodeObj'
bc_merge(barcodeObj_x, barcodeObj_y)
# S3 method for class 'BarcodeObj'
barcodeObj_x + barcodeObj_y
# S3 method for class 'BarcodeObj'
barcodeObj - black_list
# S3 method for class 'BarcodeObj'
barcodeObj * white_listA BarcodeObj object.
A character vector or integer vector or an expression
(expressio not applicable for [] operator), specifying the samples in
the subsets. When the value is an expression, the columns in the metadata can
be used as a variable.
A vector of integer or string, indicating the selected barcode.
A character vector, specifying the black list with excluded barcodes.
A logical value. If TRUE, the expression in
sample argument will not be evaluated before executing the function.
A BarcodeObj object.
A BarcodeObj object.
A character vector, giving the barcode white list.
A BarcodeObj object.
bc_subset and []: Gets samples and barcodes subset from a
BarcodeObj object.
+: Combines two BarcodeObj objects. The metadata,
cleanBc and
messyBc slot in the BarcodeObj objects will be joined.
For the metadata slot, the sample_name column, and the
Full outer join (the record in either BarcodeObj object) will be
performed with row names as the key.
The messyBc and cleanBc from two objects are combined by rows
for the same sample from two BarcodeObj objects.
-: removes barcodes in the black_list.
*: selects barcodes in the white_list.
data(bc_obj)
bc_obj
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 3 field(s) available:
#> raw_read_count barcode_read_count depth_cutoff
#> ----------
#> @messyBc: 2 sample(s) for raw barcodes:
#> In sample $test1 there are: 10 Tags
#> In sample $test2 there are: 9 Tags
#> ----------
#> @cleanBc: 2 samples for cleaned barcodes
#> In sample $test1 there are: 4 barcodes
#> In sample $test2 there are: 5 barcodes
# Select barcodes
bc_subset(bc_obj, barcode = c("AACCTT", "AACCTT"))
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 3 field(s) available:
#> raw_read_count barcode_read_count depth_cutoff
#> ----------
#> @messyBc: 2 sample(s) for raw barcodes:
#> In sample $test1 there are: 0 Tags
#> In sample $test2 there are: 0 Tags
#> ----------
#> @cleanBc: 2 samples for cleaned barcodes
#> In sample $test1 there are: 0 barcodes
#> In sample $test2 there are: 0 barcodes
bc_obj[c("AGAG", "AAAG"), ]
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 3 field(s) available:
#> raw_read_count barcode_read_count depth_cutoff
#> ----------
#> @messyBc: 2 sample(s) for raw barcodes:
#> In sample $test1 there are: 6 Tags
#> In sample $test2 there are: 5 Tags
#> ----------
#> @cleanBc: 2 samples for cleaned barcodes
#> In sample $test1 there are: 2 barcodes
#> In sample $test2 there are: 2 barcodes
# Select samples by metadata
bc_meta(bc_obj)$phenotype <- c("l", "b")
bc_meta(bc_obj)
#> raw_read_count barcode_read_count depth_cutoff phenotype
#> test1 184 178 5 l
#> test2 124 118 5 b
bc_subset(bc_obj, phenotype == "l")
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 4 field(s) available:
#> raw_read_count barcode_read_count depth_cutoff phenotype
#> ----------
#> @messyBc: 1 sample(s) for raw barcodes:
#> In sample $test1 there are: 10 Tags
#> ----------
#> @cleanBc: 1 samples for cleaned barcodes
#> In sample $test1 there are: 4 barcodes
# Select samples by sample name
bc_obj[, "test1"]
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 4 field(s) available:
#> raw_read_count barcode_read_count depth_cutoff phenotype
#> ----------
#> @messyBc: 1 sample(s) for raw barcodes:
#> In sample $test1 there are: 10 Tags
#> ----------
#> @cleanBc: 1 samples for cleaned barcodes
#> In sample $test1 there are: 4 barcodes
bc_obj[, c("test1", "test2")]
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 4 field(s) available:
#> raw_read_count barcode_read_count depth_cutoff phenotype
#> ----------
#> @messyBc: 2 sample(s) for raw barcodes:
#> In sample $test1 there are: 10 Tags
#> In sample $test2 there are: 9 Tags
#> ----------
#> @cleanBc: 2 samples for cleaned barcodes
#> In sample $test1 there are: 4 barcodes
#> In sample $test2 there are: 5 barcodes
bc_subset(bc_obj, sample = "test1", barcode = c("AACCTT", "AACCTT"))
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 4 field(s) available:
#> raw_read_count barcode_read_count depth_cutoff phenotype
#> ----------
#> @messyBc: 1 sample(s) for raw barcodes:
#> In sample $test1 there are: 0 Tags
#> ----------
#> @cleanBc: 1 samples for cleaned barcodes
#> In sample $test1 there are: 0 barcodes
# Apply barcode blacklist
bc_subset(
bc_obj,
sample = c("test1", "test2"),
barcode = c("AACCTT"))
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 4 field(s) available:
#> raw_read_count barcode_read_count depth_cutoff phenotype
#> ----------
#> @messyBc: 2 sample(s) for raw barcodes:
#> In sample $test1 there are: 0 Tags
#> In sample $test2 there are: 0 Tags
#> ----------
#> @cleanBc: 2 samples for cleaned barcodes
#> In sample $test1 there are: 0 barcodes
#> In sample $test2 there are: 0 barcodes
# Join two samples with different barcode sets
bc_obj["AGAG", "test1"] + bc_obj["AAAG", "test2"]
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 8 field(s) available:
#> raw_read_count.bc_obj["AGAG", "test1"] barcode_read_count.bc_obj["AGAG", "test1"] depth_cutoff.bc_obj["AGAG", "test1"] phenotype.bc_obj["AGAG", "test1"] raw_read_count.bc_obj["AAAG", "test2"] barcode_read_count.bc_obj["AAAG", "test2"] depth_cutoff.bc_obj["AAAG", "test2"] phenotype.bc_obj["AAAG", "test2"]
#> ----------
#> @messyBc: 2 sample(s) for raw barcodes:
#> In sample $test1 there are: 3 Tags
#> In sample $test2 there are: 2 Tags
#> ----------
#> @cleanBc: 2 samples for cleaned barcodes
#> In sample $test1 there are: 1 barcodes
#> In sample $test2 there are: 1 barcodes
# Join two samples with overlap barcodes
bc_obj_join <- bc_obj["AGAG", "test1"] + bc_obj["AGAG", "test2"]
bc_obj_join
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 8 field(s) available:
#> raw_read_count.bc_obj["AGAG", "test1"] barcode_read_count.bc_obj["AGAG", "test1"] depth_cutoff.bc_obj["AGAG", "test1"] phenotype.bc_obj["AGAG", "test1"] raw_read_count.bc_obj["AGAG", "test2"] barcode_read_count.bc_obj["AGAG", "test2"] depth_cutoff.bc_obj["AGAG", "test2"] phenotype.bc_obj["AGAG", "test2"]
#> ----------
#> @messyBc: 2 sample(s) for raw barcodes:
#> In sample $test1 there are: 3 Tags
#> In sample $test2 there are: 3 Tags
#> ----------
#> @cleanBc: 2 samples for cleaned barcodes
#> In sample $test1 there are: 1 barcodes
#> In sample $test2 there are: 1 barcodes
# The same barcode will be removed after applying bc_cure_depth()
bc_cure_depth(bc_obj_join)
#> ------------
#> bc_cure_depth: isUpdate is TRUE, update the cleanBc.
#> ------------
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 9 field(s) available:
#> raw_read_count.bc_obj["AGAG", "test1"] barcode_read_count.bc_obj["AGAG", "test1"] depth_cutoff.bc_obj["AGAG", "test1"] phenotype.bc_obj["AGAG", "test1"] raw_read_count.bc_obj["AGAG", "test2"] barcode_read_count.bc_obj["AGAG", "test2"] depth_cutoff.bc_obj["AGAG", "test2"] phenotype.bc_obj["AGAG", "test2"] depth_cutoff
#> ----------
#> @messyBc: 2 sample(s) for raw barcodes:
#> In sample $test1 there are: 3 Tags
#> In sample $test2 there are: 3 Tags
#> ----------
#> @cleanBc: 2 samples for cleaned barcodes
#> In sample $test1 there are: 1 barcodes
#> In sample $test2 there are: 1 barcodes
# Remove barcodes
bc_obj
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 4 field(s) available:
#> raw_read_count barcode_read_count depth_cutoff phenotype
#> ----------
#> @messyBc: 2 sample(s) for raw barcodes:
#> In sample $test1 there are: 10 Tags
#> In sample $test2 there are: 9 Tags
#> ----------
#> @cleanBc: 2 samples for cleaned barcodes
#> In sample $test1 there are: 4 barcodes
#> In sample $test2 there are: 5 barcodes
bc_obj - "AAAG"
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 4 field(s) available:
#> raw_read_count barcode_read_count depth_cutoff phenotype
#> ----------
#> @messyBc: 2 sample(s) for raw barcodes:
#> In sample $test1 there are: 7 Tags
#> In sample $test2 there are: 7 Tags
#> ----------
#> @cleanBc: 2 samples for cleaned barcodes
#> In sample $test1 there are: 3 barcodes
#> In sample $test2 there are: 4 barcodes
# Select barcodes in a whitelist
bc_obj
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 4 field(s) available:
#> raw_read_count barcode_read_count depth_cutoff phenotype
#> ----------
#> @messyBc: 2 sample(s) for raw barcodes:
#> In sample $test1 there are: 10 Tags
#> In sample $test2 there are: 9 Tags
#> ----------
#> @cleanBc: 2 samples for cleaned barcodes
#> In sample $test1 there are: 4 barcodes
#> In sample $test2 there are: 5 barcodes
bc_obj * "AAAG"
#> Bonjour le monde, This is a BarcodeObj.
#> ----------
#> It contains:
#> ----------
#> @metadata: 4 field(s) available:
#> raw_read_count barcode_read_count depth_cutoff phenotype
#> ----------
#> @messyBc: 2 sample(s) for raw barcodes:
#> In sample $test1 there are: 3 Tags
#> In sample $test2 there are: 2 Tags
#> ----------
#> @cleanBc: 2 samples for cleaned barcodes
#> In sample $test1 there are: 1 barcodes
#> In sample $test2 there are: 1 barcodes
###