Did the stuff on this morning’s TODO which came out of this morning’s meeting: do a PCA without the oddball strains (already done in the worksheet), highlight reference strains, and add L.major IDs and Descriptions (done by appending a collapsed version of the ortholog data to the all_lp_annot data).
Fixed human IDs for the macrophage data.
Changed input metadata sheets: primarily because I only remembered yesterday to finish the SL search for samples >TMRC20095. They are running now and will be added momentarily (I will have to redownload the sheet).
Setting up to make a hclust/phylogenetic tree of strains, use these are reference: 2168(2.3), 2272(2.2), for other 2.x choose arbitrarily (lower numbers are better).
Added another sanitize columns call for Antimony vs. antimony and None vs. none in the TMRC2 macrophage samples.
This document is intended to create the data structures used to evaluate our TMRC2 samples. In some cases, this includes only those samples starting in 2019; in other instances I am including our previous (2015-2016) samples.
In all cases the processing performed was:
I am thinking that this meeting will bring Maria Adelaida fully back into the analyses of the parasite data, and therefore may focus primarily on the goals rather than the analyses?
In a couple of important ways the TMRC2 data is much more complex than the TMRC3:
Our shared online sample sheet is nearly static at the time of this writing (202209), I expect at this point the only likely updates will be to annotate some strains as more or less susceptible to drug treatment.
sample_sheet <- "sample_sheets/ClinicalStrains_TMRC2.xlsx"
macrophage_sheet <- "sample_sheets/tmrc2_macrophage_samples.xlsx"The following block provides an example invocation of how I automatically extract things like percent reads mapped/trimmed/etc from the logs produced by trimomatic/cutadapt/hisat/salmon/etc. The caveat is that this container only has a small portion of the material available in the main working tree, as a result the new columns added to the sample sheet are relatively sparse compared to what I get on my computer.
In addition, because these samples have gone through ~ 3 different versions of my pipeline, and the code which extracts the numbers explicitly assumes only the most recent version (because it is the best!), it does not get out the data for all the samples.
## Checking the state of the condition column.
## Checking the state of the batch column.
## Checking the condition factor.
## preprocessing/TMRC20001/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20002/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20065/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20004/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20005/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20066/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20039/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20037/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20038/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20067/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20068/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20041/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20015/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20009/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20010/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20016/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20011/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20012/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20013/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20017/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20014/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20018/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20019/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20070/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20020/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20021/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20022/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20024/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20036/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20069/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20033/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20026/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20031/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20076/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20073/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20055/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20079/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20071/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20078/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20094/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20042/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20058/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20072/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20059/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20048/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20057/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20088/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20056/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20060/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20077/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20074/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20063/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20053/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20052/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20064/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20075/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20051/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20050/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20049/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20062/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20110/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20080/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20043/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20083/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20054/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20085/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20046/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20093/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20089/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20047/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20090/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20044/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20045/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20105/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20108/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20109/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20098/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20096/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20101/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20092/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20082/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20102/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20099/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20100/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20091/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20084/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20087/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20103/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20104/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20086/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20107/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20081/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## preprocessing/TMRC20095/outputs/*hisat*_lpanamensis_v36/lpanamensis_v36_*genome*_gene_ID_fcounts.csv.xz
## Writing new metadata to: sample_sheets/ClinicalStrains_TMRC2_modified.xlsx
Everything which follows depends on the Existing TriTrypDB annotations revision 46, circa 2019. The following block loads a database of these annotations and turns it into a matrix where the rows are genes and columns are all the annotation types provided by TriTrypDB.
The same database was used to create a matrix of orthologous genes between L.panamensis and all of the other species in the TriTrypDB.
The same database of annotations also provides mappings to the set of annotated GO categories for the L.panamensis genome along with gene lengths.
The following block assumes one has access to tritrypdb.org, which is no currently guaranteed. Thus I bundled a pre-generated copy of the genome, Txdb, and annotations.
## meta <- download_eupath_metadata(webservice = "tritrypdb", eu_version = "v46")
meta <- download_eupath_metadata(webservice = "tritrypdb")
panamensis_entry <- get_eupath_entry("MHOM", metadata = meta[["valid"]])
panamensis_db <- make_eupath_orgdb(panamensis_entry)
panamensis_pkg <- panamensis_db[["pkgname"]]
package_name <- panamensis_db[["pkgname"]]
if (is.null(panamensis_pkg)) {
panamensis_pkg <- panamensis_db[["orgdb_name"]]
package_name <- panamensis_pkg
}
tt <- library(panamensis_pkg, character.only = TRUE)
panamensis_pkg <- get0(panamensis_pkg)
all_fields <- columns(panamensis_pkg)
all_lp_annot <- sm(load_orgdb_annotations(
panamensis_pkg,
keytype = "gid",
fields = c("annot_gene_entrez_id", "annot_gene_name",
"annot_strand", "annot_chromosome", "annot_cds_length",
"annot_gene_product")))$genes
lp_go <- load_orgdb_go(package_name)
lp_go <- lp_go[, c("GID", "GO")]
lp_lengths <- all_lp_annot[, c("gid", "annot_cds_length")]
colnames(lp_lengths) <- c("ID", "length")
all_lp_annot[["annot_gene_product"]] <- tolower(all_lp_annot[["annot_gene_product"]])
orthos <- sm(extract_eupath_orthologs(db = panamensis_pkg))
data_structures <- c(data_structures, "lp_lengths", "lp_go", "all_lp_annot", "meta")all_installed <- rownames(installed.packages())
candidates <- grepl(pattern = "^org.Lpanamensis.MHOM.*v68.eg.db", x = all_installed)
orgdb_pkg_name <- all_installed[candidates]
tt <- library(orgdb_pkg_name, character.only = TRUE)## Error in library(orgdb_pkg_name, character.only = TRUE): 'package' must be of length 1
## Error in get0(orgdb_pkg_name): invalid first argument
## Error in columns(panamensis_pkg): could not find function "columns"
all_lp_annot <- sm(load_orgdb_annotations(
panamensis_pkg,
keytype = "gid",
fields = c("annot_gene_entrez_id", "annot_gene_name", "annot_gene_location_text",
"annot_strand", "annot_chromosome", "annot_cds_length",
"annot_gene_product")))$genes## Error: object 'panamensis_pkg' not found
## Error: object 'panamensis_pkg' not found
## Error: object 'lp_go' not found
## Error: object 'all_lp_annot' not found
## Error: object 'lp_lengths' not found
## Error: object 'all_lp_annot' not found
Recently there was a request to include the Leishmania major gene IDs and descriptions. Thus I will extract them along with the orthologs and append that to the annotations used.
Having spent the time to run the following code, I realized that the orthologs data structure above actually already has the gene IDs and descriptions.
Thus I will leave my query in place to extract the major annotations, but follow it up with a collapse of the major orthologs and appending of that to the panamensis annotations.
orgdb <- "org.Lmajor.Friedlin.v49.eg.db"
tt <- sm(library(orgdb, character.only = TRUE))
major_db <- org.Lmajor.Friedlin.v49.eg.db
all_fields <- columns(pan_db)
all_lm_annot <- sm(load_orgdb_annotations(
major_db,
keytype = "gid",
fields = c("annot_gene_entrez_id", "annot_gene_name",
"annot_strand", "annot_chromosome", "annot_cds_length",
"annot_gene_product")))$genes
wanted_orthos_idx <- orthos[["ORTHOLOGS_SPECIES"]] == "Leishmania major strain Friedlin"
sum(wanted_orthos_idx)
wanted_orthos <- orthos[wanted_orthos_idx, ]
wanted_orthos <- wanted_orthos[, c("GID", "ORTHOLOGS_ID", "ORTHOLOGS_NAME")]
collapsed_orthos <- wanted_orthos %>%
group_by(GID) %>%
summarise(collapsed_id = stringr::str_c(ORTHOLOGS_ID, collapse = " ; "),
collapsed_name = stringr::str_c(ORTHOLOGS_NAME, collapse = " ; "))
all_lp_annot <- merge(all_lp_annot, collapsed_orthos, by.x = "row.names",
by.y = "GID", all.x = TRUE)
rownames(all_lp_annot) <- all_lp_annot[["Row.names"]]
all_lp_annot[["Row.names"]] <- NULL
data_structures <- c(data_structures, "lp_lengths", "lp_go", "all_lp_annot")The following block loads the full genome sequence for panamensis. We may use this later to attempt to estimate PCR primers to discern strains.
I am not sure how to increase the number of open files in a container, as a result this does not work.
## testing_panamensis <- make_eupath_bsgenome(entry = panamensis_entry, eu_version = "v46")
pkg_candidates <- grepl(x = all_installed, pattern = "BSGenome\\.Leishmania\\.panamensis.*")
pkg_name <- all_installed[pkg_candidates][1]
library(as.character(pkg_name), character.only = TRUE)## Error in library(as.character(pkg_name), character.only = TRUE): invalid package name
The process of sample estimation takes two primary inputs:
An expressionSet(or summarizedExperiment) is a data structure used in R to examine RNASeq data. It is comprised of annotations, metadata, and expression data. In the case of our processing pipeline, the location of the expression data is provided by the filenames in the metadata.
The following samples are much lower coverage:
There is a set of strains which acquired resistance in vitro. These are included in the dataset, but there are not likely enough of them to query that question explicitly.
The following list contains the colors we have chosen to use when plotting the various ways of discerning the data.
color_choices <- list(
"strain" = list(
## "z1.0" = "#333333", ## Changed this to 'braz' to make it easier to find them.
"z2.0" = "#555555",
"z3.0" = "#777777",
"z2.1" = "#874400",
"z2.2" = "#0000cc",
"z2.3" = "#cc0000",
"z2.4" = "#df7000",
"z3.2" = "#888888",
"z1.0" = "#cc00cc",
"z1.5" = "#cc00cc",
"b2904" = "#cc00cc",
"unknown" = "#cbcbcb"),
## "null" = "#000000"),
"zymo" = list(
"z22" = "#0000cc",
"z23" = "#cc0000"),
"cf" = list(
"cure" = "#006f00",
"fail" = "#9dffa0",
"unknown" = "#cbcbcb",
"notapplicable" = "#000000"),
"susceptibility" = list(
"resistant" = "#8563a7",
"sensitive" = "#8d0000",
"ambiguous" = "#cbcbcb",
"unknown" = "#555555"))
data_structures <- c(data_structures, "color_choices")The data structure ‘lp_se’ contains the data for all samples which have hisat2 count tables, and which pass a few initial quality tests (e.g. they must have more than 8550 genes with >0 counts and >5e6 reads which mapped to a gene); genes which are annotated with a few key redundant categories (leishmanolysin for example) are also culled.
There are a few metadata columns which we really want to make certain are standardized.
Note: I changed this to print both the number of reads and genes for removed samples.
202510: Commenting out the semantic filter and will either not apply it or move it to somewhere after the visualization of the data.
sanitize_columns <- c("passagenumber", "clinicalresponse", "clinicalcategorical",
"zymodemecategorical", "included")
lp_se <- create_se(sample_sheet,
gene_info = all_lp_annot,
annotation_name = orgdb_pkg_name,
savefile = glue("rda/tmrc2_lp_se_all_raw-v{ver}.rda"),
id_column = "hpglidentifier",
file_column = "lpanamensisv36hisatfile") %>%
set_conditions(fact = "zymodemecategorical", colors = color_choices[["strain"]]) %>%
## semantic_filter(semantic = c("amastin", "gp63", "leishmanolysin"),
## semantic_column = "annot_gene_product") %>%
sanitize_metadata(columns = sanitize_columns) %>%
subset_se(subset = "included=='yes'") %>%
set_factors(columns = sanitize_columns, class = "factor")## Reading the sample metadata.
## Did not find the column: hpglidentifier.
## Setting the ID column to the first column.
## Checking the state of the condition column.
## Checking the state of the batch column.
## Checking the condition factor.
## The sample definitions comprises: 93 rows(samples) and 74 columns(metadata fields).
## Error in h(simpleError(msg, call)): error in evaluating the argument 'se' in selecting a method for function 'set_factors': error in evaluating the argument 'input' in selecting a method for function 'sanitize_metadata': error in evaluating the argument 'exp' in selecting a method for function 'set_conditions': object 'all_lp_annot' not found
data_structures <- c(data_structures, "lp_se")
save(list = "lp_se", file = glue("rda/tmrc2_lp_se_all_sanitized-v{ver}.rda"))## Error in save(list = "lp_se", file = glue("rda/tmrc2_lp_se_all_sanitized-v{ver}.rda")): object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'assay': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
all_sensitive_ids <- colData(lp_se)[["qualitativeclassificationofdrugsusceptibility"]] == "Sensitive"## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error: object 'sensitive_ids' not found
all_resistant_ids <- colData(lp_se)[["qualitativeclassificationofdrugsusceptibility"]] == "Resistant"## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error: object 'resistant_ids' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error: object 'z23_ids' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error: object 'z22_ids' not found
## Error: object 'z22_ids' not found
## Error: object 'both_ids' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error: object 'z23_ids' not found
## Error: object 'both_ids' not found
All the following data will derive from this starting point.
Here is a table of my current classifier’s interpretation of the strains.
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error: object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'merged_zymo' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'merged_zymo' not found
## Error: object 'merged_zymo' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'merged_zymo' not found
## Error: object 'merged_zymo' not found
keepers <- colData(merged_zymo)[["zymodeme"]] == "z22" |
colData(merged_zymo)[["zymodeme"]] == "z23"## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'merged_zymo' not found
merged_zymo <- merged_zymo[, keepers] %>%
set_conditions(fact = "zymodeme", colors = color_choices[["zymo"]])## Error in h(simpleError(msg, call)): error in evaluating the argument 'exp' in selecting a method for function 'set_conditions': object 'merged_zymo' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'data' in selecting a method for function 'plot_libsize': object 'lp_se' not found
## Error: object 'pre_libsize' not found
## Error: object 'pre_libsize' not found
## png
## 2
## Error in h(simpleError(msg, call)): error in evaluating the argument 'data' in selecting a method for function 'plot_nonzero': object 'lp_se' not found
## Error: object 'pre_nonzero' not found
## Error: object 'pre_nonzero' not found
## png
## 2
## Error: object 'lp_se' not found
## Error: object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'data' in selecting a method for function 'plot_nonzero': object 'lp_se' not found
## Error: object 'post_nonzero' not found
Column ‘Q’ in the sample sheet, make a categorical version of it with these parameters:
Note that these cutoffs are only valid for the historical data. The newer susceptibility data uses a cutoff of 0.78 for sensitive. I will set ambiguous to 0.5 to 0.78?
max_resist_historical <- 0.35
min_sensitive_historical <- 0.49
## 202305: Removed ambiguous category for the current set.
max_resist_current <- 0.77
min_sensitive_current <- 0.77The sanitize_percent() function seeks to make the percentage values recorded by excel more reliable. Unfortunately, sometimes excel displays the value ‘49%’ when the information recorded in the worksheet is any one of the following:
Thus, the following block will sanitize these percentage values into a single decimal number and make a categorical variable from it using pre-defined values for resistant/ambiguous/sensitive. This categorical variable will be stored in a new column: ‘sus_category_historical’.
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error: object 'st' not found
## Error: object 'st' not found
## Error: object 'starting' not found
## Error: object 'starting' not found
## Error: object 'starting' not found
## Error: object 'na_idx' not found
## Error: object 'sus_categorical' not found
## Error: object 'starting' not found
## Error: object 'sus_categorical' not found
## Error: object 'starting' not found
## Error: object 'sus_categorical' not found
## Error: object 'starting' not found
## Error: object 'sus_categorical' not found
## Error: object 'sus_categorical' not found
## Error: object 'sus_categorical' not found
## Error: object 'sus_categorical' not found
two_sankey <- plot_meta_sankey(
merged_zymo, factors = c("zymodeme", "clinicalcategorical", "susceptibility"),
drill_down = TRUE, color_choices = color_choices)## Error in h(simpleError(msg, call)): error in evaluating the argument 'design' in selecting a method for function 'plot_meta_sankey': object 'merged_zymo' not found
## Error: object 'two_sankey' not found
The same process will be repeated for the current iteration of the sensitivity assay and stored in the ‘sus_category_current’ column.
starting_current <- sanitize_percent(colData(lp_se)[["susceptibilityinfectionreduction32ugmlsbvcurrentdata"]])## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_se' not found
## Error: object 'starting_current' not found
## Error: object 'starting_current' not found
## Error: object 'na_idx' not found
## Error: object 'sus_categorical_current' not found
## The following is only valid when we had three categories, resistant/ambiguous/sensitive
## The new cutoffs drop ambiguous.
#resist_idx <- starting_current <= max_resist_current
#sus_categorical_current[resist_idx] <- "resistant"
#indeterminant_idx <- starting_current > max_resist_current &
# starting_current < min_sensitive_current
#sus_categorical_current[indeterminant_idx] <- "ambiguous"
#susceptible_idx <- starting_current >= min_sensitive_current
#sus_categorical_current[susceptible_idx] <- "sensitive"
#sus_categorical_current <- as.factor(sus_categorical_current)
resist_idx <- starting_current <= max_resist_current## Error: object 'starting_current' not found
## Error: object 'resist_idx' not found
## Error: object 'sus_categorical_current' not found
## Error: object 'sus_categorical_current' not found
## Error: object 'sus_categorical_current' not found
## Error: object 'sus_categorical_current' not found
## Error: object 'sus_categorical_current' not found
## Error: object 'sus_categorical_current' not found
lp_sankey <- plot_meta_sankey(
lp_se, factors = c("zymodemecategorical", "clinicalcategorical", "susceptibility"),
drill_down = TRUE, color_choices = color_choices)## Error in h(simpleError(msg, call)): error in evaluating the argument 'design' in selecting a method for function 'plot_meta_sankey': object 'lp_se' not found
## Error: object 'lp_sankey' not found
In many queries, we will seek to compare only the two primary strains, zymodeme 2.2 and 2.3. The following block will extract only those samples.
Note: IMPORTANT Maria Adelaida prefers not to use lp_two_strains. We should not at this time use the merged 2.1/2.2 and 2.4/2.3 categories.
lp_strain <- lp_se %>%
set_batches(fact = sus_categorical_current) %>%
set_colors(color_choices[["strain"]])## Error in h(simpleError(msg, call)): error in evaluating the argument 'exp' in selecting a method for function 'set_colors': error in evaluating the argument 'exp' in selecting a method for function 'set_batches': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_strain' not found
## Error in save(list = "lp_strain", file = glue("rda/tmrc2_lp_strain-v{ver}.rda")): object 'lp_strain' not found
## Error: object 'merged_zymo' not found
## Error in save(list = "lp_two_strains", file = glue("rda/tmrc2_lp_two_strains-v{ver}.rda")): object 'lp_two_strains' not found
Clinical outcome is by far the most problematic comparison in this data, but here is the recategorization of the data using it:
lp_cf <- set_conditions(lp_se, fact = "clinicalcategorical",
colors = color_choices[["cf"]]) %>%
set_batches(fact = sus_categorical_current)## Error in h(simpleError(msg, call)): error in evaluating the argument 'exp' in selecting a method for function 'set_batches': error in evaluating the argument 'exp' in selecting a method for function 'set_conditions': object 'lp_se' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_cf' not found
data_structures <- c(data_structures, "lp_cf")
save(list = "lp_cf", file = glue("rda/tmrc2_lp_cf-v{ver}.rda"))## Error in save(list = "lp_cf", file = glue("rda/tmrc2_lp_cf-v{ver}.rda")): object 'lp_cf' not found
## Error: object 'lp_cf' not found
data_structures <- c(data_structures, "lp_cf_known")
save(list = "lp_cf_known", file = glue("rda/tmrc2_lp_cf_known-v{ver}.rda"))## Error in save(list = "lp_cf_known", file = glue("rda/tmrc2_lp_cf_known-v{ver}.rda")): object 'lp_cf_known' not found
data_structures <- c(data_structures, "lp_cf_known")
save(list = "lp_cf_known", file = glue("rda/tmrc2_lp_cf_known-v{ver}.rda"))## Error in save(list = "lp_cf_known", file = glue("rda/tmrc2_lp_cf_known-v{ver}.rda")): object 'lp_cf_known' not found
Use the factorized version of susceptibility to categorize the samples by the historical data.
lp_susceptibility_historical <- set_conditions(
lp_se, fact = "sus_category_historical", colors = color_choices[["susceptibility"]]) %>%
set_batches(fact = "clinicalcategorical")## Error in h(simpleError(msg, call)): error in evaluating the argument 'exp' in selecting a method for function 'set_batches': error in evaluating the argument 'exp' in selecting a method for function 'set_conditions': object 'lp_se' not found
save(list = "lp_susceptibility_historical",
file = glue("rda/tmrc2_lp_susceptibility_historical-v{ver}.rda"))## Error in save(list = "lp_susceptibility_historical", file = glue("rda/tmrc2_lp_susceptibility_historical-v{ver}.rda")): object 'lp_susceptibility_historical' not found
Use the factorized version of susceptibility to categorize the samples by the historical data.
This will likely be our canonical susceptibility dataset, so I will remove the suffix and just call it ‘lp_susceptibility’.
lp_susceptibility <- set_conditions(
lp_se, fact = "sus_category_current", colors = color_choices[["susceptibility"]]) %>%
set_batches(fact = "clinicalcategorical")## Error in h(simpleError(msg, call)): error in evaluating the argument 'exp' in selecting a method for function 'set_batches': error in evaluating the argument 'exp' in selecting a method for function 'set_conditions': object 'lp_se' not found
## Error in save(list = "lp_susceptibility", file = glue("rda/tmrc2_lp_susceptibility-v{ver}.rda")): object 'lp_susceptibility' not found
I think this is redundant with a previous block, but I am leaving it until I am certain that it is not required in a following document.
Note: IMPORTANT This is the set Maria Adeliada prefers to use.
## Error: object 'lp_se' not found
data_structures <- c(data_structures, "lp_zymo")
save(list = "lp_zymo", file = glue("rda/tmrc2_lp_zymo-v{ver}.rda"))## Error in save(list = "lp_zymo", file = glue("rda/tmrc2_lp_zymo-v{ver}.rda")): object 'lp_zymo' not found
The following section will create some initial data structures of the observed variants in the parasite samples. This will include some of our 2016 samples for some classification queries.
I changed and improved the mapping and variant detection methods from what we used for the 2016 data. So some small changes will be required to merge them.
lp_previous <- create_se("sample_sheets/tmrc2_samples_20191203.xlsx",
file_column = "tophat2file",
savefile = glue("rda/lp_previous-v{ver}.rda"))
tt <- lp_previous$expressionset
rownames(tt) <- gsub(pattern = "^exon_", replacement = "", x = rownames(tt))
rownames(tt) <- gsub(pattern = "\\.1$", replacement = "", x = rownames(tt))
rownames(tt) <- gsub(pattern = "\\-1$", replacement = "", x = rownames(tt))
lp_previous$expressionset <- tt
rm(tt)
data_structures <- c(data_structures, "lp_previous")The count_se_snps() function uses our expressionset data and a metadata column in order to extract the mpileup or freebayes-based variant calls and create matrices of the likelihood that each position-per-sample is in fact a variant.
There is an important caveat here which changed on 202301: I was interpreting using the PAIRED tag, which is only used for, unsurprisingly, paired-end samples. A couple samples are not paired and so were failing silently. The QA tag looks like it is more appropriate and should work across both types. One way to find out, I am setting it here and will look to see if the results make more sense for my test samples (TMRC2001, TMRC2005, TMRC2007).
## The next line drops the samples which are missing the SNP pipeline.
lp_snp <- subset_se(lp_se, subset = "!is.na(colData(lp_se)[['freebayessummary']])")## Error: object 'lp_se' not found
## Error: object 'lp_snp' not found
lp_snp_only22_23_ref <- subset_se(lp_snp, subset = "zymodemereference=='z2.2'|zymodemereference=='z2.3'") %>%
subset_se(subset = "rownames!='TMRC20082'")## Error: object 'lp_snp' not found
lp_snp_22_23_ml <- subset_se(lp_snp, subset = "knnv2classification=='z22'|knnv2classification=='z23'") %>%
subset_se(subset = "rownames!='TMRC20082'")## Error: object 'lp_snp' not found
new_snps_sufficient <- count_snps(lp_snp_sufficient, annot_column = "freebayessummary",
snp_column = "QA", reader = "readr")## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_snp_sufficient' not found
new_snps_only22_23_ref_suf <- count_snps(lp_snp_only22_23_ref, annot_column = "freebayessummary",
snp_column = "QA", reader = "readr")## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_snp_only22_23_ref' not found
new_snps_22_23_ml_suf <- count_snps(lp_snp_22_23_ml, annot_column = "freebayessummary",
snp_column = "QA", reader = "readr")## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_snp_22_23_ml' not found
## Lets see if we get numbers which make sense.
summary(assay(new_snps_sufficient)[["TMRC20001"]]) ## My weirdo sample## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'assay': object 'new_snps_sufficient' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'assay': object 'new_snps_sufficient' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'assay': object 'new_snps_sufficient' not found
## Now that we are reasonably confident that things make more sense, lets save and move on...
data_structures <- c(data_structures, "new_snps_sufficient", "lp_snp")
## Most of the time I just run normalize() and assume it will dispatch to normalize_se()
sufficient_norm <- normalize(new_snps_sufficient, transform = "log2")## Error in h(simpleError(msg, call)): error in evaluating the argument 'exp' in selecting a method for function 'normalize': object 'new_snps_sufficient' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'data' in selecting a method for function 'plot_boxplot': object 'sufficient_norm' not found
Now let us pull in the 2016 data.
old_snps <- count_snps(lp_previous, annot_column = "bcftable", snp_column = 2)
data_structures <- c(data_structures, "old_snps")
save(list = "lp_snp", file = glue("rda/lp_snp-v{ver}.rda"))
data_structures <- c(data_structures, "lp_snp")
save(list = "new_snps", file = glue("rda/new_snps-v{ver}.rda"))
data_structures <- c(data_structures, "new_snps")
save(list = "old_snps", file = glue("rda/old_snps-v{ver}.rda"))
data_structures <- c(data_structures, "old_snps")
nonzero_snps <- assay(new_snps) != 0
colSums(nonzero_snps)As far as I can tell, freebayes and mpileup are reasonably similar in their sensitivity/specificity; so combining the two datasets like this is expected to work with minimal problems. The most likely problem is that my mpileup-based pipeline is unable to handle indels.
I am taking a heatmap from our variant data and manually identifying sample groups.
All of the above focused entire on the parasite samples, now let us pull up the macrophage infected samples. This will comprise two datasets, one of the human and one of the parasite.
The metadata for the macrophage samples contains a couple of columns for mapped human and parasite reads. We will therefore use them separately to create two expressionsets, one for each species.
## Using mart: ENSEMBL_MART_ENSEMBL from host: apr2020.archive.ensembl.org.
## Successfully connected to the hsapiens_gene_ensembl database.
## Finished downloading ensembl gene annotations.
## Finished downloading ensembl structure annotations.
## symbol columns is null, pattern matching 'symbol' and taking the first.
## Including symbols, there are 67149 vs the 249740 gene annotations.
## Not dropping haplotype chromosome annotations, set drop_haplotypes = TRUE if this is bad.
## Saving annotations to hsapiens_biomart_annotations.rda.
## Finished save().
hs_annot <- hs_annot[["annotation"]]
hs_annot[["transcript"]] <- paste0(rownames(hs_annot), ".", hs_annot[["transcript_version"]])
rownames(hs_annot) <- make.names(hs_annot[["ensembl_gene_id"]], unique = TRUE)
rownames(hs_annot) <- paste0("gene:", rownames(hs_annot))
tx_gene_map <- hs_annot[, c("transcript", "ensembl_gene_id")]
sanitize_columns <- c("drug", "macrophagetreatment", "macrophagezymodeme")
macr_annot <- hs_annot
rownames(macr_annot) <- gsub(x = rownames(macr_annot),
pattern = "^gene:",
replacement = "")
hs_macrophage <- create_se(macrophage_sheet, gene_info = macr_annot,
file_column = "hg38100hisatfile") %>%
set_conditions(fact = "macrophagetreatment") %>%
set_batches(fact = "macrophagezymodeme") %>%
sanitize_metadata(columns = sanitize_columns) %>%
subset_se(nonzero = 12000)## Reading the sample metadata.
## Did not find the column: sampleid.
## Setting the ID column to the first column.
## Did not find the condition column in the sample sheet.
## Filling it in as undefined.
## Did not find the batch column in the sample sheet.
## Filling it in as undefined.
## Checking the state of the condition column.
## Checking the state of the batch column.
## Checking the condition factor.
## The sample definitions comprises: 69 rows(samples) and 80 columns(metadata fields).
## Matched 21481 annotations and counts.
## Some annotations were lost in merging, setting them to 'undefined'.
## The final summarized experiment has 21481 rows and 80 columns.
## The numbers of samples by condition are:
##
## inf inf_sb uninf uninf_sb
## 30 29 5 5
## The number of samples by batch are:
##
## none z2.2 z2.3
## 10 30 29
## Recasting the data.frame to DataFrame.
## rownames tubelabelorigin samplename numberofvials
## Length:69 Length:69 Length:69 Min. :1
## Class :character Class :character Class :character 1st Qu.:1
## Mode :character Mode :character Mode :character Median :1
## Mean :1
## 3rd Qu.:1
## Max. :1
##
## sourcelab expperson cellssource samplecollectiondate
## Length:69 Length:69 Length:69 Min. :20190629
## Class :character Class :character Class :character 1st Qu.:20210813
## Mode :character Mode :character Mode :character Median :20220827
## Mean :20212685
## 3rd Qu.:20220827
## Max. :20220916
##
## typeofcells donor isolationmethod
## Length:69 Length:69 Length:69
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
##
## cellspurificationmethod selectionmethod rnapreservation
## Length:69 Length:69 Length:69
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
##
## rnaextractiondate rnavolumeul rnaavailableul rnaqctesteddate
## Length:69 Min. :30 Min. : 5.2 Min. : 42382
## Class :character 1st Qu.:30 1st Qu.:22.2 1st Qu.:20200114
## Mode :character Median :30 Median :23.3 Median :20205521
## Mean :30 Mean :23.1 Mean :19485696
## 3rd Qu.:30 3rd Qu.:25.6 3rd Qu.:20211111
## Max. :30 Max. :26.2 Max. :20211221
## NA's :41 NA's :41 NA's :41
## bioanalyzerrnangul rnaqcpassed rin nanodroprnangul
## Length:69 Length:69 Length:69 Length:69
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## x260280 x260230 rnausedtoconstructlibrariesul
## Length:69 Length:69 Min. : 2.20
## Class :character Class :character 1st Qu.: 2.80
## Mode :character Mode :character Median : 3.41
## Mean : 4.61
## 3rd Qu.: 4.83
## Max. :23.30
## NA's :41
## rnausedtoconstructlibrariesng libraryqctesteddate libqcpassed
## Min. : 0.5 Min. :20200115 Length:69
## 1st Qu.: 0.5 1st Qu.:20200115 Class :character
## Median :250.3 Median :20201221 Mode :character
## Mean :275.3 Mean :20205505
## 3rd Qu.:500.0 3rd Qu.:20211219
## Max. :800.0 Max. :20211223
## NA's :41 NA's :42
## index libraryvolumeul libraryvolumesenttonajibslabul
## Min. : 1.0 Min. :28 Min. :15
## 1st Qu.: 7.0 1st Qu.:28 1st Qu.:15
## Median :14.5 Median :28 Median :15
## Mean :13.9 Mean :28 Mean :15
## 3rd Qu.:20.2 3rd Qu.:28 3rd Qu.:15
## Max. :27.0 Max. :28 Max. :15
## NA's :41 NA's :41 NA's :41
## shipmentdate oldnew countersampleatcideimul drug
## Min. :20200217 Length:69 Min. :13 antimony:34
## 1st Qu.:20200217 Class :character 1st Qu.:13 none :35
## Median :20210558 Mode :character Median :13
## Mean :20210188 Mean :13
## 3rd Qu.:20220103 3rd Qu.:13
## Max. :20220103 Max. :13
## NA's :41 NA's :56
## descriptonandremarks observation
## Length:69 Length:69
## Class :character Class :character
## Mode :character Mode :character
##
##
##
##
## librarybioanalyzerprofileelsayedlabfilenamewelllane libraryconcnm
## Length:69 Min. : 22.1
## Class :character 1st Qu.: 57.8
## Mode :character Median : 98.7
## Mean : 96.2
## 3rd Qu.:112.8
## Max. :218.0
## NA's :55
## samplefor100ul2or4nmsequencing waterfor100ul2or4nmsequencing
## Min. :0.917 Min. :92.0
## 1st Qu.:1.754 1st Qu.:96.9
## Median :1.942 Median :98.1
## Mean :2.995 Mean :97.0
## 3rd Qu.:3.082 3rd Qu.:98.2
## Max. :8.000 Max. :99.1
## NA's :56 NA's :56
## sequencingorderno seqorderdate seqcompletedate totalreads
## Length:69 Min. :20200901 Min. :20200910 Min. :12254196
## Class :character 1st Qu.:20200901 1st Qu.:20200910 1st Qu.:21496945
## Mode :character Median :20200901 Median :20200910 Median :23391483
## Mean :20202287 Mean :20202296 Mean :29119440
## 3rd Qu.:20200901 3rd Qu.:20200910 3rd Qu.:27612540
## Max. :20210601 Max. :20210610 Max. :86048061
## NA's :55 NA's :55
## trimmedreads percentkept hg38100salmonfile hg38100hisatfile
## Min. :10400801 Min. :0.735 Length:69 Length:69
## 1st Qu.:19375511 1st Qu.:0.887 Class :character Class :character
## Median :21401552 Median :0.902 Mode :character Mode :character
## Mean :26367248 Mean :0.903
## 3rd Qu.:25048428 3rd Qu.:0.940
## Max. :79775170 Max. :0.945
##
## hisatsinglemappedhg38 hisatmultimappedhg38 hisatmappingratehg38
## Min. : 501881 Min. : 328180 Min. :0.0418
## 1st Qu.:17620997 1st Qu.: 605198 1st Qu.:0.9114
## Median :18986346 Median : 682134 Median :0.9606
## Mean :23074608 Mean :1339401 Mean :0.9223
## 3rd Qu.:22472518 3rd Qu.: 830271 3rd Qu.:0.9787
## Max. :70100660 Max. :7030835 Max. :0.9885
##
## lpanamensisv36hisatfile hisatlpsinglemapped hisatlpmultimapped
## Length:69 Min. : 199 Min. : 14
## Class :character 1st Qu.: 11504 1st Qu.: 770
## Mode :character Median : 284271 Median : 17386
## Mean : 909574 Mean : 70729
## 3rd Qu.:1006681 3rd Qu.: 81008
## Max. :7086371 Max. :620799
##
## parasitemappingrate parasitehostratio x68 macrophagetreatment
## Min. :0.000011 Min. :0.000204 Length:69 inf :30
## 1st Qu.:0.000487 1st Qu.:0.003393 Class :character inf_sb :29
## Median :0.010078 Median :0.003393 Mode :character uninf : 5
## Mean :0.036938 Mean :0.010336 uninf_sb: 5
## 3rd Qu.:0.048453 3rd Qu.:0.003393
## Max. :0.292395 Max. :0.155351
##
## macrophagezymodeme strainid slr1fwd slr1rc
## none:10 Length:69 Min. : 0.00 Min. : 0
## z22 :30 Class :character 1st Qu.: 0.00 1st Qu.: 0
## z23 :29 Mode :character Median : 0.00 Median : 6
## Mean : 1.16 Mean : 31
## 3rd Qu.: 1.00 3rd Qu.: 27
## Max. :11.00 Max. :641
##
## slr2fwd slr2rc slsum slvsreads
## Min. : 2 Min. : 0.000 Min. : 2 Min. :1.03e-07
## 1st Qu.: 224 1st Qu.: 0.000 1st Qu.: 225 1st Qu.:7.81e-06
## Median : 4249 Median : 0.000 Median : 4300 Median :1.83e-04
## Mean : 17256 Mean : 0.667 Mean : 17289 Mean :6.68e-04
## 3rd Qu.: 22089 3rd Qu.: 0.000 3rd Qu.: 22188 3rd Qu.:8.17e-04
## Max. :168826 Max. :13.000 Max. :169487 Max. :6.57e-03
##
## slvshuman trimomatic_input trimomatic_output trimomatic_percent
## Min. :1.05e-07 Length:69 Length:69 Length:69
## 1st Qu.:1.06e-05 Class :character Class :character Class :character
## Median :1.87e-04 Mode :character Mode :character Mode :character
## Mean :8.21e-04
## 3rd Qu.:8.79e-04
## Max. :1.02e-02
##
## fastqc_pct_gc hisat_genome_single_concordant
## Length:69 Length:69
## Class :character Class :character
## Mode :character Mode :character
##
##
##
##
## hisat_genome_multi_concordant hisat_genome_single_all hisat_genome_multi_all
## Length:69 Length:69 Length:69
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
##
## hisat_genome_percent hisat_count_table condition batch
## Length:69 Length:69 Length:69 Length:69
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## The samples (and read coverage) removed when filtering 12000 non-zero genes are:
## TMRC30162
## 521145
## TMRC30162
## 10208
## Samples removed: 10208
fixed_genenames <- gsub(x = rownames(assay(hs_macrophage)), pattern = "^gene:",
replacement = "")
hs_macrophage <- set_genenames(hs_macrophage, ids = fixed_genenames)
table(colData(hs_macrophage)$condition)##
## inf inf_sb uninf uninf_sb
## 29 29 5 5
## The following 3 lines were copy/pasted to datastructures and should be removed soon.
nostrain <- is.na(colData(hs_macrophage)[["strainid"]])
colData(hs_macrophage)[nostrain, "strainid"] <- "none"
colData(hs_macrophage)[["strain_zymo"]] <- paste0("s", colData(hs_macrophage)[["strainid"]],
"_", colData(hs_macrophage)[["macrophagezymodeme"]])
uninfected <- colData(hs_macrophage)[["strain_zymo"]] == "snone_none"
colData(hs_macrophage)[uninfected, "strain_zymo"] <- "uninfected"
data_structures <- c(data_structures, "hs_macrophage")Finally, split off the U937 samples.
In the previous block, we used a new invocation of ensembl-derived annotation data, this time we can just use our existing parasite gene annotations.
lp_macrophage <- create_se(macrophage_sheet, file_column = "lpanamensisv36hisatfile",
gene_info = all_lp_annot,
savefile = glue("rda/lp_macrophage-v{ver}.rda"),
annotation = "org.Lpanamensis.MHOMCOL81L13.v46.eg.db") %>%
set_conditions(fact = "macrophagezymodeme") %>%
set_batches(fact = "macrophagetreatment")## Reading the sample metadata.
## Did not find the column: sampleid.
## Setting the ID column to the first column.
## Did not find the condition column in the sample sheet.
## Filling it in as undefined.
## Did not find the batch column in the sample sheet.
## Filling it in as undefined.
## Checking the state of the condition column.
## Checking the state of the batch column.
## Checking the condition factor.
## The sample definitions comprises: 69 rows(samples) and 80 columns(metadata fields).
## Warning in create_se(macrophage_sheet, file_column = "lpanamensisv36hisatfile",
## : Some samples were removed when cross referencing the samples against the
## count data.
## Error in h(simpleError(msg, call)): error in evaluating the argument 'exp' in selecting a method for function 'set_batches': error in evaluating the argument 'exp' in selecting a method for function 'set_conditions': object 'all_lp_annot' not found
unfilt_written <- write_se(
lp_macrophage,
excel = glue("analyses/macrophage_de/{ver}/read_counts/lp_macrophage_reads_unfiltered-v{ver}.xlsx"))## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'ncol': error in evaluating the argument 'x' in selecting a method for function 'assay': object 'lp_macrophage' not found
## Error: object 'lp_macrophage' not found
## semantic_filter(semantic = c("amastin", "gp63", "leishmanolysin"),
## semantic_column = "annot_gene_product")
data_structures <- c(data_structures, "lp_macrophage", "lp_macrophage_filt")
filt_written <- write_se(lp_macrophage_filt,
excel = glue("analyses/macrophage_de/{ver}/read_counts/lp_macrophage_reads_filtered-v{ver}.xlsx"))## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'ncol': error in evaluating the argument 'x' in selecting a method for function 'assay': object 'lp_macrophage_filt' not found
## Error: object 'lp_macrophage_filt' not found
## Error: object 'lp_macrophage' not found
lp_nosb_write <- write_se(
lp_macrophage_nosb,
excel = glue("analyses/macrophage_de/{ver}/read_counts/lp_macrophage_nosb_reads-v{ver}.xlsx"))## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'ncol': error in evaluating the argument 'x' in selecting a method for function 'assay': object 'lp_macrophage_nosb' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_macrophage' not found
## Error: object 'lp_meta' not found
## Error: object 'lp_meta' not found
## Error: object 'lp_meta' not found
color_vector <- as.character(color_choices[["strain"]])
names(color_vector) <- names(color_choices[["strain"]])
color_vector <- color_vector[c("z2.2", "z2.3", "unknown")]
names(color_vector) <- c("z2.2", "z2.3", "none")
sl_violin <- ggplot(lp_meta,
aes(x = .data[["condition"]], y = .data[["slvsreads_log"]],
fill = .data[["condition"]])) +
geom_violin() +
geom_point() +
scale_fill_manual(values = color_vector)## Error: object 'lp_meta' not found
## Error: object 'sl_violin' not found
## Error: object 'lp_meta' not found
I want to make an estimate of ploidy using transcriptomic data. This is by definition a foold’s errand, but I think it might work.
lp_rpkm <- normalize(lp_se, convert = "rpkm", filter = TRUE,
length_column = "annot_cds_length", na_to_zero = TRUE)## Error in h(simpleError(msg, call)): error in evaluating the argument 'exp' in selecting a method for function 'normalize': object 'lp_se' not found
## Exclude scaffolds
unwanted <- grepl(pattern = "SCAF", x = rowData(lp_rpkm)[["annot_gene_location_text"]])## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'rowData': object 'lp_rpkm' not found
## Error: object 'lp_rpkm' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'assay': object 'lp_wanted' not found
## Error: object 'summary_df' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'rowData': object 'lp_wanted' not found
## Error: object 'summary_df' not found
## Error: object 'summary_df' not found
summary_df <- summary_df[, c("gene_mean", "chromosome")] %>%
group_by(chromosome) %>%
summarize(chr_mean = mean(gene_mean, na.rm = TRUE))## Error: object 'summary_df' not found
## Error: object 'summary_df' not found
## Error: object 'summary_df' not found
## Error: object 'summary_df' not found
wanted <- colData(lp_wanted)[["knnv2classification"]] == "z22" | colData(lp_wanted)[["knnv2classification"]] == "z23"## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_wanted' not found
## Error: object 'lp_wanted' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_z' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'colData': object 'lp_z' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'assay': object 'lp_z' not found
## Error: object 'lp_z_assay' not found
## Error: object 'lp_z_assay' not found
## Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'rowData': object 'lp_z' not found
lp_z_means <- lp_z_assay[, c("z22_gene_mean", "z23_gene_mean", "chromosome")] %>%
group_by(chromosome) %>%
summarize(z22_mean = mean(z22_gene_mean, na.rm = TRUE),
z23_mean = mean(z23_gene_mean, na.rm = TRUE))## Error: object 'lp_z_assay' not found
## Error: object 'lp_z_means' not found
chr_reshaped[["chromosome"]] <- factor(chr_reshaped[["chromosome"]],
levels = c(as.character(1:19), "20.1", "20.2",
as.character(21:35)))## Error: object 'chr_reshaped' not found
putative_aneuploid <- ggplot(chr_reshaped, aes(x = value, y = chromosome)) +
geom_bar(aes(fill = variable), position = "dodge", stat = "identity")## Error: object 'chr_reshaped' not found
## Error: object 'putative_aneuploid' not found
## png
## 2
## Error: object 'putative_aneuploid' not found
found_idx <- data_structures %in% ls()
if (sum(!found_idx) > 0) {
not_found <- data_structures[!found_idx]
warning("Some datastructures were not generated: ", toString(not_found), ".")
data_structures <- data_structures[found_idx]
}## Warning: Some datastructures were not generated: lp_lengths, lp_go,
## all_lp_annot, meta, lp_se, lp_strain, lp_two_strains, lp_cf, lp_cf_known,
## lp_cf_known, lp_susceptibility_historical, lp_susceptibility, lp_zymo,
## new_snps_sufficient, lp_snp, lp_macrophage, lp_macrophage_filt,
## lp_macrophage_nosb.
## Warning: Your system is mis-configured: '/etc/localtime' is not a symlink
## Warning: It is strongly recommended to set envionment variable TZ to
## 'America/New_York' (or equivalent)
R version 4.5.0 (2025-04-11)
Platform: x86_64-pc-linux-gnu
locale: C
attached base packages: stats, graphics, grDevices, utils, datasets, methods and base
other attached packages: hpgltools(v.1.2), Heatplus(v.3.16.0), ggplot2(v.4.0.0), glue(v.1.8.0) and dplyr(v.1.1.4)
loaded via a namespace (and not attached): RColorBrewer(v.1.1-3), jsonlite(v.2.0.0), correlation(v.0.8.8), datawizard(v.1.2.0), magrittr(v.2.0.4), farver(v.2.1.2), rmarkdown(v.2.29), fs(v.1.6.6), vctrs(v.0.6.5), memoise(v.2.0.1), paletteer(v.1.6.0), effectsize(v.1.0.1), htmltools(v.0.5.8.1), S4Arrays(v.1.8.1), progress(v.1.2.3), curl(v.7.0.0), broom(v.1.0.10), SparseArray(v.1.8.1), sass(v.0.4.10), bslib(v.0.9.0), htmlwidgets(v.1.6.4), plyr(v.1.8.9), httr2(v.1.2.1), plotly(v.4.11.0), cachem(v.1.1.0), mime(v.0.13), lifecycle(v.1.0.4), iterators(v.1.0.14), pkgconfig(v.2.0.3), Matrix(v.1.7-3), R6(v.2.6.1), fastmap(v.1.2.0), GenomeInfoDbData(v.1.2.14), MatrixGenerics(v.1.20.0), shiny(v.1.11.1), digest(v.0.6.37), rematch2(v.2.1.2), patchwork(v.1.3.2), AnnotationDbi(v.1.70.0), S4Vectors(v.0.46.0), GenomicRanges(v.1.60.0), RSQLite(v.2.4.3), filelock(v.1.0.3), httr(v.1.4.7), abind(v.1.4-8), compiler(v.4.5.0), pander(v.0.6.6), bit64(v.4.6.0-1), withr(v.3.0.2), S7(v.0.2.0), backports(v.1.5.0), BiocParallel(v.1.42.1), DBI(v.1.2.3), R.utils(v.2.13.0), biomaRt(v.2.64.0), rappdirs(v.0.3.3), DelayedArray(v.0.34.1), tools(v.4.5.0), zip(v.2.3.3), httpuv(v.1.6.16), statsExpressions(v.1.7.1), varhandle(v.2.0.6), R.oo(v.1.27.1), GOSemSim(v.2.34.0), promises(v.1.3.3), grid(v.4.5.0), reshape2(v.1.4.4), fgsea(v.1.34.2), generics(v.0.1.4), gtable(v.0.3.6), tzdb(v.0.5.0), R.methodsS3(v.1.8.2), tidyr(v.1.3.1), data.table(v.1.17.8), hms(v.1.1.3), xml2(v.1.4.0), XVector(v.0.48.0), BiocGenerics(v.0.54.0), foreach(v.1.5.2), pillar(v.1.11.0), stringr(v.1.5.1), yulab.utils(v.0.2.1), vroom(v.1.6.5), later(v.1.4.3), splines(v.4.5.0), BiocFileCache(v.2.16.1), lattice(v.0.22-7), bit(v.4.6.0), annotate(v.1.86.1), ggstatsplot(v.0.13.3), tidyselect(v.1.2.1), GO.db(v.3.21.0), Biostrings(v.2.76.0), knitr(v.1.50), IRanges(v.2.42.0), SummarizedExperiment(v.1.38.1), stats4(v.4.5.0), xfun(v.0.53), Biobase(v.2.68.0), matrixStats(v.1.5.0), stringi(v.1.8.7), UCSC.utils(v.1.4.0), lazyeval(v.0.2.2), yaml(v.2.3.10), evaluate(v.1.0.4), codetools(v.0.2-20), tibble(v.3.3.0), qvalue(v.2.40.0), graph(v.1.86.0), cli(v.3.6.5), RcppParallel(v.5.1.11-1), parameters(v.0.28.2), xtable(v.1.8-4), jquerylib(v.0.1.4), dichromat(v.2.0-0.1), Rcpp(v.1.1.0), GenomeInfoDb(v.1.44.2), zeallot(v.0.2.0), dbplyr(v.2.5.0), png(v.0.1-8), XML(v.3.99-0.19), parallel(v.4.5.0), rstantools(v.2.5.0), readr(v.2.1.5), blob(v.1.2.4), prettyunits(v.1.2.0), bayestestR(v.0.17.0), DOSE(v.4.2.0), viridisLite(v.0.4.2), GSEABase(v.1.70.0), scales(v.1.4.0), insight(v.1.4.2), openxlsx(v.4.2.8), purrr(v.1.1.0), crayon(v.1.5.3), rlang(v.1.1.6), cowplot(v.1.2.0), fastmatch(v.1.1-6) and KEGGREST(v.1.48.1)
## If you wish to reproduce this exact build of hpgltools, invoke the following:
## > git clone http://github.com/abelew/hpgltools.git
## > git reset b479ad4aea5c11ece084c588c57777c08d864a5a
## This is hpgltools commit: Thu Oct 9 17:14:10 2025 -0400: b479ad4aea5c11ece084c588c57777c08d864a5a
## Saving to 01datasets.rda.xz