Skip to content

Commit

Permalink
tidy vignette handled by FormatR
Browse files Browse the repository at this point in the history
To avoid adding styler as a recommended package when the package is already using FormatR, tidy code handling by knitr is all conducted with FormatR. Also added, consistant spacing between headers and code blocks in the object structure vignette and edited some phrasing of structure explainations.
  • Loading branch information
jmitchell81 committed Dec 7, 2023
1 parent 1eabd10 commit 412ed0c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
3 changes: 1 addition & 2 deletions vignettes/domino2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ vignette: >
%\VignetteEncoding{UTF-8}
---


```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
Expand All @@ -16,7 +15,7 @@ knitr::opts_chunk$set(
message = FALSE,
warning = FALSE,
fig.cap="",
tidy = "styler",
tidy = TRUE,
global.device = TRUE
)
options(timeout=300)
Expand Down
34 changes: 27 additions & 7 deletions vignettes/domino_object_vignette.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ knitr::opts_chunk$set(
message = FALSE,
warning = FALSE,
fig.cap="",
tidy = "styler"
tidy = TRUE,
global.device = TRUE
)
options(timeout=300)
```
Expand All @@ -35,18 +36,19 @@ dom <- readRDS(paste0(temp_dir, "/pbmc_domino_built.rds"))

# The new domino object structure

In order to better implement some of the changes that have been made in domino2, the structure of the domino object has been modified. Here, we describe the data that is stored in the domino object, as well as how best to access it for any other use you may have in mind.
In order to better implement some of the changes that have been made in domino2, the structure of the domino object has been modified. Here, we describe the data that is stored in the domino object, as well as how best to access this data.

## Object contents

The contents of the domino object class include a few broad groups:
- input data, such as the L-R database used, counts, and z-scores
- calculations, such as correlations or differential expression results
- linkages, which show connections between TFs, receptors, and ligands across the data set and within clusters
- signaling matrices, which show signaling from ligands to receptors in clusters (or a summary of overall signaling)
- signaling matrices, which show expression of ligands signaling to active receptors in clusters (or a summary of overall signaling)
- build information, which includes the parameters used to build the object in the `build_domino()` functions

For commonly accessed information (the number of cells, clusters, and some build information), the show and print methods for domino objects can be used.

```{r show}
dom
```
Expand All @@ -64,45 +66,54 @@ ls("package:domino2", pattern = "^dom_")
```

### Input data

When creating a domino object with the `create_domino()` function, several inputs are required which are then stored in the domino object itself. These include cluster labels, the counts matrix, z-scored counts matrix, transcription factor activation scores, and the R-L database used in `create_rl_map_cellphonedb()`.

For example, to access the cluster names in the domino object:

```{r cluster-names}
dom_clusters(dom)
```

Setting an argument `labels = TRUE` will return the vector of cluster labels for each cell rather than the unique cluster names.

To access the counts:

```{r counts}
count_matrix <- dom_counts(dom)
knitr::kable(count_matrix[1:5, 1:5])
```

Or z-scored counts:

```{r zcounts}
z_matrix <- dom_zscores(dom)
knitr::kable(z_matrix[1:5, 1:5])
```

The transcription factor activation scores can be similarly accessed:

```{r tf_activation}
activation_matrix <- dom_tf_activation(dom)
knitr::kable(activation_matrix[1:5, 1:5])
```

Information about the database inputted can be extracted from the `dom_database()` function. By default, the function returns the name(s) of the database(s) used:
Information about the database referenced for ligand-receptor pairs and composition of protien complexes can be extracted from the `dom_database()` function. By default, the function returns the name(s) of the database(s) used:

```{r db-name}
dom_database(dom)
```

But if you would like to view the entire ligand-receptor map, set `name_only = FALSE`:
If you would like to view the entire ligand-receptor map, set `name_only = FALSE`:

```{r db-all}
db_matrix <- dom_database(dom, name_only = FALSE)
knitr::kable(db_matrix[1:5, 1:5])
```

### Calculations
Active transcription factors in each cluster are determined by conducting wilcoxon rank sum tests for each transcription factor where the trascription factor activity scores amongst all cells in the cluster are tested against the activity scores of all cells outside of the cluster. The p-value for the one-sided test for greater activity within the cluster compared to outside can be accessed with the `dom_de()` function.

Active transcription factors in each cluster are determined by conducting wilcoxon rank sum tests for each transcription factor where the transcription factor activity scores amongst all cells in a cluster are tested against the activity scores of all cells outside of the cluster. The p-values for the one-sided test for greater activity within the cluster compared to outside can be accessed with the `dom_de()` function.

```{r de}
de_matrix <- dom_de(dom)
Expand All @@ -117,38 +128,46 @@ knitr::kable(cor_matrix[1:5, 1:5])
```

### Linkages
Linkages between various ligands, receptors, and transcription factors can be accessed in several different ways, depending on the specific link and the scope desired. The `dom_linkages()` function has three arguments - the first, like all of our access functions, is for the domino object. The second, `link_type`, is used to specify which linkages are desired (options are complexes, receptor-ligand, tf-target, or tf-receptor). The third argument, `by_cluster`, determines whether the linkages returned are arranged by cluster (though this does change the available linkage types to tf-receptor, receptor, or incoming-ligand). For example, to access the complexes used across the dataset:

Linkages between ligands, receptors, and transcription factors can be accessed in several different ways, depending on the specific link and the scope desired. The `dom_linkages()` function has three arguments - the first, like all of our access functions, is for the domino object. The second, `link_type`, is used to specify which linkages are desired (options are complexes, receptor-ligand, tf-target, or tf-receptor). The third argument, `by_cluster`, determines whether the linkages returned are arranged by cluster (though this does change the available linkage types to tf-receptor, receptor, or incoming-ligand). For example, to access the complexes used across the dataset:

```{r, complex}
complex_links <- dom_linkages(dom, link_type = "complexes")
# Look for components of NODAL receptor complex
complex_links$NODAL_receptor
```

To view incoming ligands to each cluster:

```{r, lig-by-clust}
incoming_links <- dom_linkages(dom, link_type = "incoming-ligand", by_cluster = TRUE)
# Check incoming signals to dendritic cells
incoming_links$dendritic_cell
```

If, for some reason, you find yourself in need of the entire linkage structure (not recommended), it can be accessed through its slot name; domino objects are S4 objects.

```{r link}
all_linkages <- slot(dom, "linkages")
# Names of all sub-structures:
names(all_linkages)
```

Alternately, to obtain a simplified list of receptors, ligands, and\/or features in the domino object, use the `collate_network_items()` function. To pull all receptors associated with the dendritic cell cluster:

```{r collate}
collate_network_items(dom, "dendritic_cell", return = "features")
```

### Signaling Matrices

The averaged z-scored expression of ligands and receptors between different clusters can be accessed in matrix form.

```{r global-signalling}
signal_matrix <- dom_signaling(dom)
knitr::kable(signal_matrix)
```

To view signaling to a specific cluster from the other clusters, set the `cluster` argument to the cluster name.

```{r clust-signal}
Expand All @@ -157,6 +176,7 @@ knitr::kable(dc_matrix)
```

### Build information

To keep track of the options set when running `build_domino()`, they are stored within the domino object itself. To view these options, use the `dom_info()` function.

```{r info}
Expand Down
2 changes: 1 addition & 1 deletion vignettes/plotting_vignette.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ knitr::opts_chunk$set(
message = FALSE,
warning = FALSE,
fig.cap="",
tidy = "styler",
tidy = TRUE,
global.device = TRUE
)
options(timeout=300)
Expand Down

0 comments on commit 412ed0c

Please sign in to comment.