Skip to content

Commit

Permalink
resolve build check warnings/errors in latest R-devel
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeDMorgan committed Apr 29, 2024
1 parent 69fd5cd commit b00d66c
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 2,364 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: miloR
Type: Package
Title: Differential neighbourhood abundance testing on a graph
Version: 1.99.14
Version: 1.99.15
Authors@R:
c(person("Mike", "Morgan", role=c("aut", "cre"), email="michael.morgan@abdn.ac.uk",
comment=c(ORCID="0000-0003-0757-0711")),
Expand Down Expand Up @@ -68,7 +68,7 @@ Suggests:
curl,
scRNAseq,
graphics
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
NeedsCompilation: no
Packaged: 2020-07-31 14:15:28 UTC; morgan02
Collate:
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ importFrom(Matrix,Matrix)
importFrom(Matrix,colSums)
importFrom(Matrix,crossprod)
importFrom(Matrix,diag)
importFrom(Matrix,kronecker)
importFrom(Matrix,rowMeans)
importFrom(Matrix,rowSums)
importFrom(Matrix,solve)
Expand Down Expand Up @@ -156,7 +157,6 @@ importFrom(igraph,as_ids)
importFrom(igraph,cluster_louvain)
importFrom(igraph,components)
importFrom(igraph,count_triangles)
importFrom(igraph,graph.adjacency)
importFrom(igraph,graph_from_adjacency_matrix)
importFrom(igraph,induced_subgraph)
importFrom(igraph,is_igraph)
Expand Down
4 changes: 2 additions & 2 deletions R/buildFromAdjacency.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ buildFromAdjacency <- function(x, k=NULL, is.binary=NULL, ...){
if(is.square){
if(!is.binary){
bin.x <- as(matrix(as.numeric(x > 0), nrow=nrow(x)), "dgCMatrix")
nn.graph <- graph_from_adjacency_matrix(bin.x, mode="undirected",
nn.graph <- graph_from_adjacency_matrix(bin.x, mode="max",
weighted=NULL,
diag=FALSE)
} else{
nn.graph <- graph_from_adjacency_matrix(x, mode="undirected",
nn.graph <- graph_from_adjacency_matrix(x, mode="max",
weighted=NULL,
diag=FALSE)
}
Expand Down
4 changes: 2 additions & 2 deletions R/buildNhoodGraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#'
#' NULL
#'
#' @importFrom igraph graph.adjacency set_vertex_attr vertex.attributes
#' @importFrom igraph graph_from_adjacency_matrix set_vertex_attr vertex.attributes
#' @export
#' @rdname buildNhoodGraph
buildNhoodGraph <- function(x, overlap=1){
Expand All @@ -42,7 +42,7 @@ buildNhoodGraph <- function(x, overlap=1){
nhoodAdjacency(x) <- nh_intersect_mat

## Make igraph object
ig <- graph.adjacency(nh_intersect_mat, mode="undirected", weighted=TRUE)
ig <- graph_from_adjacency_matrix(nh_intersect_mat, mode="undirected", weighted=TRUE)
nhood_sizes <- colSums(nhoods(x))
ig <- set_vertex_attr(ig, name = 'size', value = nhood_sizes[vertex.attributes(ig)$name])
## Add to nhoodGraph slot in milo object
Expand Down
2 changes: 1 addition & 1 deletion R/miloR.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' as representative neighbourhoods on a nearest neighbour graph. Hypothesis testing is performed using a
#' negative bionomial generalized linear model.
#'
#' @docType package
#' @aliases miloR-package
#' @importFrom Rcpp evalCpp
#' @useDynLib miloR
#' @name miloR
Expand Down
2 changes: 1 addition & 1 deletion man/miloR.Rd

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

2 changes: 1 addition & 1 deletion src/Makevars
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#PKG_CXXFLAGS = $(CXX11STD) -Wall -pedantic
CXX11STD = CXX11
PKG_CXXFLAGS = $(CFLAGS) $(CXX11STD) $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CXXFLAGS)
ALL_CXXFLAGS = $(R_XTRA_CXXFLAGS) $(PKG_CXXFLAGS) $(CXXPICFLAGS) $(SHLIB_CXXFLAGS) $(CXXFLAGS)
2 changes: 1 addition & 1 deletion tests/testthat/test_buildGraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ test_that("buildGraph can take different inputs", {
expect_true(igraph::identical_graphs(miloR::graph(buildGraph(sim1.pca$x, transposed=TRUE, k=21)), sim1.graph))

# input are expression values
graph.diff <- graph.difference(miloR::graph(buildGraph(sim1.gex, transposed=FALSE, k=21)), sim1.graph)
graph.diff <- difference(miloR::graph(buildGraph(sim1.gex, transposed=FALSE, k=21)), sim1.graph)

expect_true(length(E(graph.diff)) == 0)
expect_true(length(V(graph.diff)) == length(V(sim1.graph)))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_buildNhoodGraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test_that("Code produced identical output", {
rownames(nh_intersect_mat) <- colnames(nhoods)
colnames(nh_intersect_mat) <- colnames(nhoods)

ig <- graph.adjacency(nh_intersect_mat, mode="undirected", weighted=TRUE)
ig <- graph_from_adjacency_matrix(nh_intersect_mat, mode="undirected", weighted=TRUE)
nhood_sizes <- sapply(nhoods(traj_milo), length)
ig <- set_vertex_attr(ig, name = 'size', value = nhood_sizes[vertex.attributes(ig)$name])

Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test_testNhoods.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ test_that("Model contrasts provide expected results", {
design.df=sim1.meta[colnames(nhoodCounts(sim1.mylo)), ]))

# test for each column of output
expect_equal(cont.ref$Pvalue, form.ref$Pvalue)
expect_equal(cont.ref$SpatialFDR, form.ref$SpatialFDR)
expect_equal(cont.ref$logFC, form.ref$logFC)
expect_equal(cont.ref$`F`, form.ref$`F`)
expect_equal(cont.ref$FDR, form.ref$FDR)
expect_equal(cont.ref$Pvalue, form.ref$Pvalue, tolerance=1e-6)
expect_equal(cont.ref$SpatialFDR, form.ref$SpatialFDR, tolerance=1e-6)
expect_equal(cont.ref$logFC, form.ref$logFC, tolerance=1e-6)
expect_equal(cont.ref$`F`, form.ref$`F`, tolerance=1e-6)
expect_equal(cont.ref$FDR, form.ref$FDR, tolerance=1e-6)
})

test_that("Providing a subset model.matrix is reproducible", {
Expand Down
12 changes: 9 additions & 3 deletions vignettes/milo_contrasts.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,17 @@ we build the KNN graph and define neighbourhoods to quantify cell abundance acro

```{r}
# we build KNN graph
thy.milo <- buildGraph(thy.milo, k = 10, d = 30)
thy.milo <- makeNhoods(thy.milo, prop = 0.1, k = 10, d=30, refined = TRUE, refinement_scheme="graph") # make nhoods using graph-only as this is faster
thy.milo <- buildGraph(thy.milo, k = 11, d = 40)
thy.milo <- makeNhoods(thy.milo, prop = 0.2, k = 11, d=40, refined = TRUE, refinement_scheme="graph") # make nhoods using graph-only as this is faster
colData(thy.milo)$Sample <- paste(colData(thy.milo)$SortDay, colData(thy.milo)$Age, sep="_")
thy.milo <- countCells(thy.milo, meta.data = data.frame(colData(thy.milo)), samples="Sample") # make the nhood X sample counts matrix
```


```{r}
plotNhoodSizeHist(thy.milo)
```

# Differential abundance testing with contrasts

Now we have the pieces in place for DA testing to demonstrate how to use contrasts. We will use these contrasts to explicitly define which groups will be
Expand All @@ -93,7 +98,8 @@ rownames(thy.design) <- thy.design$Sample
contrast.1 <- c("Age1wk - Age4wk") # the syntax is <VariableName><ConditionLevel> - <VariableName><ControlLevel>
# we need to use the ~ 0 + Variable expression here so that we have all of the levels of our variable as separate columns in our model matrix
da_results <- testNhoods(thy.milo, design = ~ 0 + Age, design.df = thy.design, model.contrasts = contrast.1, fdr.weighting="graph-overlap")
da_results <- testNhoods(thy.milo, design = ~ 0 + Age, design.df = thy.design, model.contrasts = contrast.1,
fdr.weighting="graph-overlap")
table(da_results$SpatialFDR < 0.1)
```

Expand Down
10 changes: 9 additions & 1 deletion vignettes/milo_gastrulation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ In these examples we settle for `overlap=5` and `max.lfc.delta=5`, as we need at

```{r, dev="jpeg"}
set.seed(42)
da_results <- groupNhoods(embryo_milo, da_results, max.lfc.delta = 5, overlap=5)
da_results <- groupNhoods(embryo_milo, da_results, max.lfc.delta = 1, overlap=3)
plotNhoodGroups(embryo_milo, da_results, layout="umap")
plotDAbeeswarm(da_results, group.by = "NhoodGroup")
```
Expand All @@ -348,6 +348,14 @@ embryo_milo <- embryo_milo[keep.rows, ]
set.seed(101)
dec <- modelGeneVar(embryo_milo)
hvgs <- getTopHVGs(dec, n=2000)
# this vignette randomly fails to identify HVGs for some reason
if(!length(hvgs)){
set.seed(42)
dec <- modelGeneVar(embryo_milo)
hvgs <- getTopHVGs(dec, n=2000)
}
head(hvgs)
```

Expand Down
11 changes: 9 additions & 2 deletions vignettes/milo_glmm.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,17 @@ register(bpparam)
pbmc.sce <- KotliarovPBMCData(mode="rna", ensembl=TRUE) # download the PBMC data from Kotliarov _et al._
# downsample cells to reduce compute time
prop.cells <- 0.75
n.cells <- floor(ncol(pbmc.sce) * prop.cells)
set.seed(42)
keep.cells <- sample(colnames(pbmc.sce), size=n.cells)
pbmc.sce <- pbmc.sce[, colnames(pbmc.sce) %in% keep.cells]
# downsample the number of samples
colData(pbmc.sce)$ObsID <- paste(colData(pbmc.sce)$tenx_lane, colData(pbmc.sce)$sampleid, sep="_")
n.samps <- 90
set.seed(42)
n.samps <- 80
keep.samps <- sample(unique(colData(pbmc.sce)$ObsID), size=n.samps)
keep.cells <- rownames(colData(pbmc.sce))[colData(pbmc.sce)$ObsID %in% keep.samps]
pbmc.sce <- pbmc.sce[, colnames(pbmc.sce) %in% keep.cells]
Expand Down
2,341 changes: 0 additions & 2,341 deletions vignettes/milo_glmm.html

This file was deleted.

0 comments on commit b00d66c

Please sign in to comment.