Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/neurogenomics/CHAS
Browse files Browse the repository at this point in the history
merge branches
  • Loading branch information
Kitty Murphy committed Jul 5, 2024
2 parents f62462b + d30e5f4 commit 4e7cbc1
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 179 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: CHAS
Title: Cell type deconvolution of bulk tissue histone acetylomes from epigenetic data
Version: 0.99.6
Version: 0.99.7
Description: CHAS is an R package which integrates cell sorted H3K27ac data to identify cell type-specific peaks in bulk tissue H3K27ac profiles. Using the cell type-specific H3K27ac peaks, one can then calculate cell type-specific acetylation scores to act as a proxy for cell type proportion in the bulk tissue sample.
Authors@R:
person(given = "Kitty",
Expand All @@ -12,7 +12,6 @@ biocViews:
Imports:
data.table,
dplyr,
EPIC,
edgeR,
GenomicRanges,
ggplot2,
Expand Down
42 changes: 29 additions & 13 deletions R/plot_MF_props.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,40 @@
#' for each bulk sample.
#'
#' @param celltypeProportion The output list from the function CelltypeProportion()
#' @param sampleLabel Whether or not to add sample labels to the plot. The default is FALSE.
#' @return A bar plot showing the predicted cell type proportions for each sample.
#' @import RColorBrewer
#' @export

plot_MF_props <- function(celltypeProportion){
par(mar=c(3, 4, 2, 8), xpd=TRUE)
plot_MF_props <- function(celltypeProportion, sampleLabel = FALSE){
x <- ncol(celltypeProportion[["proportions"]])-5
names(celltypeProportion[["proportions"]])[5] <- "Other"
names(celltypeProportion[["proportions"]])[5+x] <- "Other"
celltypeProportion[["proportions"]] <- celltypeProportion[["proportions"]]*100

barplot(t(celltypeProportion[["proportions"]]),
xaxt = "n", xlab = NULL, ylab = NULL, border = NA,
col = c("#446455", "#FDD262", "#46ACC8", "#F4B5BD",
brewer.pal(8, "Accent")[0:x],"#DDDDDD"))
legend("right",inset=c(-0.3,0),cex = 0.8,
names(celltypeProportion[["proportions"]]),
fill = c("#446455", "#FDD262", "#46ACC8", "#F4B5BD",
brewer.pal(8, "Accent")[0:x],"#DDDDDD"))
mtext("Samples", side=1, line=0.9, font=1, adj = 0.5, cex=1.2)
mtext("Predicted proportions (%)", side=2, line=2.5,adj=0.5, font=1,cex=1.2)
if (sampleLabel == FALSE) {
par(mar=c(3, 4, 2, 8), xpd=TRUE)
barplot(t(celltypeProportion[["proportions"]]),
xaxt = "n", xlab = NULL, ylab = NULL, border = NA,
col = c("#446455", "#FDD262", "#46ACC8", "#F4B5BD",
brewer.pal(8, "Accent")[0:x],"#DDDDDD"))
legend("right",inset=c(-0.3,0),cex = 0.8,
names(celltypeProportion[["proportions"]]),
fill = c("#446455", "#FDD262", "#46ACC8", "#F4B5BD",
brewer.pal(8, "Accent")[0:x],"#DDDDDD"))
mtext("Samples", side=1, line=0.9, font=1, adj = 0.5, cex=1.2)
mtext("Predicted proportions (%)", side=2, line=2.5,adj=0.5, font=1,cex=1.2)
} else {
par(mar=c(10, 4, 2, 8), xpd=TRUE)
par(las = 2)
barplot(t(celltypeProportion[["proportions"]]),
xlab = NULL, ylab = NULL, border = NA,
col = c("#446455", "#FDD262", "#46ACC8", "#F4B5BD",
brewer.pal(8, "Accent")[0:x],"#DDDDDD"))
legend("right",inset=c(-0.3,0),cex = 0.8,
names(celltypeProportion[["proportions"]]),
fill = c("#446455", "#FDD262", "#46ACC8", "#F4B5BD",
brewer.pal(8, "Accent")[0:x],"#DDDDDD"))
mtext("Samples", side=1, line=8, font=1, adj = 0.5, cex=1.2, las=1)
mtext("Predicted proportions (%)", side=2, line=2.5,adj=0.5, font=1,cex=1.2, las=3)
}
}
12 changes: 6 additions & 6 deletions docs/CHAS.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,19 @@ refSamples[,2] <- rep(c("Astrocyte","Microglia","Neuron","Oligodendrocyte"),each
To predict cell type proportions, run the following function on bulk and reference counts for consensus peaks.

```{r}
AD_MF <- CelltypeProportion(AD_unionCounts$bulkCounts, AD_unionCounts$refCounts,
AD_unionPeaks$unionPeaks, refSamples, AD_unionPeaks$celltypePeaks)
AD_MF <- CelltypeProportion(AD_unionCounts$bulkCounts, AD_unionCounts$refCounts,
AD_unionPeaks$unionPeaks, refSamples, AD_unionPeaks$celltypePeaks)
```

*CelltypeProportion()* takes as input the bulk and reference counts for consensus peaks, the locations of the consensus peaks, cell type annotations for reference samples, and 'signature peaks', which are consensus peaks that are found in both the bulk and reference samples. This function first calculates length-normalised cpm (counts per million) from raw counts, then calculates the median and variability for reference data, and then runs matrix factorisation on the signature peaks using the R package EPIC. The output is a list containing two items: the first item is the number of signature peaks used, and the second item is a table containing the predicted proportions of each cell type in each bulk sample. The proportion of uncharacterised cell types is also predicted in the 'otherCells' column.

### 7. Plot the predicted cell type proportions in the bulk brain samples.

``` {r, fig.width=7, fig.height=3.5}
plot_MF_props(AD_MF)
plot_MF_props(AD_MF, sampleLabel=FALSE)
```

*plot_MF_props()* uses the predicted cell type proportions from *CelltypeProportion()* to generate a stacked bar plot of the proportions of each cell type in each of the bulk brain H3K27ac samples.
*plot_MF_props()* uses the predicted cell type proportions from *CelltypeProportion()* to generate a stacked bar plot of the proportions of each cell type in each of the bulk brain H3K27ac samples. To add sample labels, set sampleLabels = TRUE.

### 8. Plot the predicted cell type proportions between two phenotype groups.

Expand Down Expand Up @@ -374,10 +374,10 @@ AD_MF_noBAM <- CelltypeProportion(AD_consensusPeaks$newBulkTPM, AD_consensusPeak
### 5. Plot the predicted cell type proportions in the bulk brain samples.

``` {r, fig.width=7, fig.height=3.5}
plot_MF_props(AD_MF_noBAM)
plot_MF_props(AD_MF_noBAM, sampleLabel=FALSE)
```

*plot_MF_props()* uses the predicted cell type proportions from *CelltypeProportion()* to generate a stacked bar plot of the proportions of each cell type in each of the bulk brain H3K27ac samples.
*plot_MF_props()* uses the predicted cell type proportions from *CelltypeProportion()* to generate a stacked bar plot of the proportions of each cell type in each of the bulk brain H3K27ac samples. To add sample labels, set sampleLabels = TRUE.

### 6. Plot the predicted cell type proportions between two phenotype groups.

Expand Down
26 changes: 13 additions & 13 deletions docs/CHAS.html

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion man/plot_MF_props.Rd

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

144 changes: 0 additions & 144 deletions vignettes/CHAS.Rmd

This file was deleted.

0 comments on commit 4e7cbc1

Please sign in to comment.