Skip to content

Commit

Permalink
Merge pull request #266 from AlexsLemonade/jashapiro/reformat
Browse files Browse the repository at this point in the history
pre-commit reformats
  • Loading branch information
allyhawkins authored Mar 8, 2024
2 parents cec2696 + de7db45 commit 2cbd61c
Show file tree
Hide file tree
Showing 9 changed files with 321 additions and 290 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha

11 changes: 5 additions & 6 deletions R/sce_to_anndata.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
#' )
#' }
sce_to_anndata <- function(
sce,
anndata_file,
x_assay_name = "counts",
compression = c("gzip", "none", "lzf"),
...
) {
sce,
anndata_file,
x_assay_name = "counts",
compression = c("gzip", "none", "lzf"),
...) {
if (!requireNamespace("zellkonverter", quietly = TRUE)) {
stop("The zellkonverter package must be installed to convert objects to AnnData. No output file written.")
}
Expand Down
55 changes: 29 additions & 26 deletions inst/rmd/cite_qc.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,34 @@

```{r}
# add rowData if missing
if (is.null(rowData(cite_exp)$detected)){
if (is.null(rowData(cite_exp)$detected)) {
cite_exp <- scuttle::addPerFeatureQCMetrics(cite_exp)
}
cell_adt_counts <- Matrix::colSums(counts(cite_exp))
cite_information <- tibble::tibble(
"Number of ADTs assayed" =
format(nrow(cite_exp), big.mark = ',', scientific = FALSE),
"CITE-seq reads sequenced" =
format(cite_meta$total_reads, big.mark = ',', scientific = FALSE),
"Percent CITE-seq reads mapped to ADTs" =
paste0(round(cite_meta$mapped_reads/cite_meta$total_reads * 100, digits = 2), "%"),
"Percent of ADTs in cells" =
paste0(round(sum(cell_adt_counts)/cite_meta$mapped_reads * 100, digits = 2), "%"),
"Percent of cells with ADTs" =
paste0(round(sum(cell_adt_counts > 0)/length(cell_adt_counts) * 100, digits = 2), "%"),
"Median ADT UMIs per cell" =
format(median(cell_adt_counts), big.mark = ',', scientific = FALSE)
)|>
"Number of ADTs assayed" =
format(nrow(cite_exp), big.mark = ",", scientific = FALSE),
"CITE-seq reads sequenced" =
format(cite_meta$total_reads, big.mark = ",", scientific = FALSE),
"Percent CITE-seq reads mapped to ADTs" =
paste0(round(cite_meta$mapped_reads / cite_meta$total_reads * 100, digits = 2), "%"),
"Percent of ADTs in cells" =
paste0(round(sum(cell_adt_counts) / cite_meta$mapped_reads * 100, digits = 2), "%"),
"Percent of cells with ADTs" =
paste0(round(sum(cell_adt_counts > 0) / length(cell_adt_counts) * 100, digits = 2), "%"),
"Median ADT UMIs per cell" =
format(median(cell_adt_counts), big.mark = ",", scientific = FALSE)
) |>
t()
knitr::kable(cite_information, align = 'r') |>
kableExtra::kable_styling(bootstrap_options = "striped",
full_width = FALSE,
position = "left") |>
knitr::kable(cite_information, align = "r") |>
kableExtra::kable_styling(
bootstrap_options = "striped",
full_width = FALSE,
position = "left"
) |>
kableExtra::column_spec(2, monospace = TRUE)
```

Expand All @@ -39,14 +41,15 @@ antibody_tags <- as.data.frame(rowData(cite_exp)) |>
tibble::rownames_to_column("Antibody") |>
arrange(desc(mean)) |>
select("Antibody",
"Mean UMI count per cell" = mean,
"Percent of cells detected" = detected)
"Mean UMI count per cell" = mean,
"Percent of cells detected" = detected
)
knitr::kable(antibody_tags, digits = 2) |>
kableExtra::kable_styling(bootstrap_options = c("striped", "condensed"),
full_width = FALSE,
position = "left",
) |>
kableExtra::column_spec(2:3, monospace = TRUE)
kableExtra::kable_styling(
bootstrap_options = c("striped", "condensed"),
full_width = FALSE,
position = "left",
) |>
kableExtra::column_spec(2:3, monospace = TRUE)
```
98 changes: 52 additions & 46 deletions inst/rmd/multiplex_qc.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,34 @@

```{r}
# add rowData if missing
if (is.null(rowData(multiplex_exp)$detected)){
if (is.null(rowData(multiplex_exp)$detected)) {
multiplex_exp <- scuttle::addPerFeatureQCMetrics(multiplex_exp)
}
cell_hto_counts <- Matrix::colSums(counts(multiplex_exp))
hto_information <- tibble::tibble(
"Number of HTOs assayed" =
format(nrow(multiplex_exp), big.mark = ',', scientific = FALSE),
"Multiplex reads sequenced" =
format(multiplex_meta$total_reads, big.mark = ',', scientific = FALSE),
"Percent multiplex reads mapped to ADTs" =
paste0(round(multiplex_meta$mapped_reads/multiplex_meta$total_reads * 100, digits = 2), "%"),
"Percent of HTOs in cells" =
paste0(round(sum(cell_hto_counts)/multiplex_meta$mapped_reads * 100, digits = 2), "%"),
"Percent of cells with HTOs" =
paste0(round(sum(cell_hto_counts > 0)/length(cell_hto_counts) * 100, digits = 2), "%"),
"Median HTO UMIs per cell" =
format(median(cell_hto_counts), big.mark = ',', scientific = FALSE)
)|>
"Number of HTOs assayed" =
format(nrow(multiplex_exp), big.mark = ",", scientific = FALSE),
"Multiplex reads sequenced" =
format(multiplex_meta$total_reads, big.mark = ",", scientific = FALSE),
"Percent multiplex reads mapped to ADTs" =
paste0(round(multiplex_meta$mapped_reads / multiplex_meta$total_reads * 100, digits = 2), "%"),
"Percent of HTOs in cells" =
paste0(round(sum(cell_hto_counts) / multiplex_meta$mapped_reads * 100, digits = 2), "%"),
"Percent of cells with HTOs" =
paste0(round(sum(cell_hto_counts > 0) / length(cell_hto_counts) * 100, digits = 2), "%"),
"Median HTO UMIs per cell" =
format(median(cell_hto_counts), big.mark = ",", scientific = FALSE)
) |>
t()
knitr::kable(hto_information, align = 'r') |>
kableExtra::kable_styling(bootstrap_options = "striped",
full_width = FALSE,
position = "left") |>
knitr::kable(hto_information, align = "r") |>
kableExtra::kable_styling(
bootstrap_options = "striped",
full_width = FALSE,
position = "left"
) |>
kableExtra::column_spec(2, monospace = TRUE)
```

Expand All @@ -40,15 +42,17 @@ hto_tags <- as.data.frame(rowData(multiplex_exp)) |>
tibble::rownames_to_column("Hashtag Oligo (HTO)") |>
arrange(desc(mean)) |>
select("Hashtag Oligo (HTO)",
"Mean UMI count per cell" = mean,
"Percent of cells detected" = detected)
"Mean UMI count per cell" = mean,
"Percent of cells detected" = detected
)
knitr::kable(hto_tags, digits = 2) |>
kableExtra::kable_styling(bootstrap_options = c("striped", "condensed"),
full_width = FALSE,
position = "left",
) |>
kableExtra::column_spec(2:3, monospace = TRUE)
kableExtra::kable_styling(
bootstrap_options = c("striped", "condensed"),
full_width = FALSE,
position = "left",
) |>
kableExtra::column_spec(2:3, monospace = TRUE)
```

## Demultiplexing Sample Calls
Expand All @@ -62,41 +66,43 @@ The genetic demultiplexing results are reported under the `vireo` column in the

```{r, results='asis'}
# grab columns that have demuxing results as not all methods could be present
# e.g. vireo is only used if a matching bulk RNA seq library is there,
# e.g. vireo is only used if a matching bulk RNA seq library is there,
# otherwise those calls will not be present
demux_methods <- c("hashedDrops_sampleid", "HTODemux_sampleid", "vireo_sampleid")
demux_columns <- colnames(colData(filtered_sce)) %in% demux_methods
if(any(demux_columns)){
# create a table summarizing demuxing calls for each method used
if (any(demux_columns)) {
# create a table summarizing demuxing calls for each method used
demux_calls <- as.data.frame(colData(filtered_sce)[, demux_columns]) |>
# remove _sampleid at the end of the column names
dplyr::rename_with(~stringr::str_remove(., "_sampleid")) |>
tidyr::pivot_longer(cols = everything(),
names_to = "demux_method",
values_to = "Sample") |>
dplyr::rename_with(~ stringr::str_remove(., "_sampleid")) |>
tidyr::pivot_longer(
cols = everything(),
names_to = "demux_method",
values_to = "Sample"
) |>
dplyr::count(Sample, demux_method) |>
tidyr::pivot_wider(names_from = demux_method,
values_from = n)
tidyr::pivot_wider(
names_from = demux_method,
values_from = n
)
knitr::kable(demux_calls, digits = 2) |>
kableExtra::kable_styling(bootstrap_options = c("striped", "condensed"),
full_width = FALSE,
position = "left",
kableExtra::kable_styling(
bootstrap_options = c("striped", "condensed"),
full_width = FALSE,
position = "left",
) |>
kableExtra::column_spec(2:ncol(demux_calls), monospace = TRUE)
}else{
kableExtra::column_spec(2:ncol(demux_calls), monospace = TRUE)
} else {
glue::glue("
<div class=\"alert alert-info\">
Demultiplexing was not applied to this library using any of the above mentioned methods.
Sample calls cannot be reported.
</div>
")
}
```


Loading

0 comments on commit 2cbd61c

Please sign in to comment.