Skip to content

Commit

Permalink
Update deprecated igraph for 2.1, #69 #70
Browse files Browse the repository at this point in the history
  • Loading branch information
hpliner committed Jan 3, 2025
1 parent 65f2c6f commit 349c1f8
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 98 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: garnett
Type: Package
Title: Automated cell type classification
Version: 0.2.20
Version: 0.2.22
Author: c(
person("Hannah", "Pliner", email = "[email protected]", role = c("aut", "cre")),
person("Cole", "Trapnell", email = "[email protected]", role = c("aut")))
Expand All @@ -16,7 +16,7 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Depends:
R (>= 3.5.0),
R (>= 4.0.0),
monocle3
Imports:
AnnotationDbi (>= 1.44.0),
Expand Down
8 changes: 4 additions & 4 deletions R/classify_cells.R
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ run_classifier <- function(classifier,
for (v in igraph::V(classifier@classification_tree)){

child_cell_types <- igraph::V(classifier@classification_tree)[
suppressWarnings(outnei(v))]$name
suppressWarnings(.outnei(v))]$name

if (length(child_cell_types) > 0){
new_gate_res <- make_predictions(cds, classifier, v,
Expand All @@ -261,7 +261,7 @@ run_classifier <- function(classifier,
imputed_gate_res, level_table){

for (child in igraph::V(classifier@classification_tree)[
suppressWarnings(outnei(v))]){
suppressWarnings(.outnei(v))]){
curr_level <- paste0("level", tree_levels[child])
if(!curr_level %in% names(level_table)) {
level_table[[curr_level]] <- "Unknown"
Expand Down Expand Up @@ -365,7 +365,7 @@ make_predictions <- function(cds,
predictions <- tryCatch({
if(is.null(cvfit)) {
child_cell_types <- igraph::V(classifier@classification_tree)[
suppressWarnings(outnei(curr_node)) ]$name
suppressWarnings(.outnei(curr_node)) ]$name
predictions <- matrix(FALSE, nrow=nrow(colData(cds)),
ncol=length(child_cell_types),
dimnames=list(row.names(colData(cds)),
Expand Down Expand Up @@ -562,7 +562,7 @@ get_communities <- function(cds) {

relations$from <- cell_names[relations$from]
relations$to <- cell_names[relations$to]
g <- igraph::graph.data.frame(relations, directed = FALSE)
g <- igraph::graph_from_data_frame(relations, directed = FALSE)

Q <- igraph::cluster_louvain(g)

Expand Down
2 changes: 1 addition & 1 deletion R/get_training_sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ get_training_sample <- function(cds,
##### Find type assignment from expressed/not expressed #####

child_cell_types <- igraph::V(classifier@classification_tree)[
suppressWarnings(outnei(curr_node)) ]$name
suppressWarnings(.outnei(curr_node)) ]$name
parent <- igraph::V(classifier@classification_tree)[curr_node]$name
if (length(child_cell_types) > 0) {
if (length(intersect(child_cell_types, colnames(marker_scores))) == 0 &
Expand Down
2 changes: 1 addition & 1 deletion R/methods-garnett_classifier.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
new_garnett_classifier <- function()
{
garc <- new( "garnett_classifier",
classification_tree = igraph::graph.empty())
classification_tree = igraph::make_empty_graph())

root_node_id <- "root"

Expand Down
6 changes: 3 additions & 3 deletions R/train_cell_classifier.R
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ train_cell_classifier <- function(cds,

for (v in igraph::V(classifier@classification_tree)){
child_cell_types <- igraph::V(classifier@classification_tree)[
suppressWarnings(outnei(v))]$name
suppressWarnings(.outnei(v))]$name

if(length(child_cell_types) > 0) {
### Get CDS subset for training ###
Expand All @@ -299,7 +299,7 @@ train_cell_classifier <- function(cds,
make_predictions(norm_cds,
classifier,
igraph::V(classifier@classification_tree)[
suppressWarnings(innei(v))]$name,
suppressWarnings(.innei(v))]$name,
rank_prob_ratio = 1.1,
s = "lambda.min")
if(!igraph::V(classifier@classification_tree)[v]$name %in%
Expand Down Expand Up @@ -581,7 +581,7 @@ propogate_func <- function(curr_node,
parse_list,
classifier) {
children <- igraph::V(classifier@classification_tree)[
suppressWarnings(outnei(curr_node))]$name
suppressWarnings(.outnei(curr_node))]$name

if(length(children) == 0) {
return(parse_list[[curr_node]]@expressed)
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ check_markers <- function(cds,
##### For each node #####
for (v in igraph::V(classifier@classification_tree)){
child_cell_types <-
igraph::V(classifier@classification_tree)[suppressWarnings(outnei(v))]$name
igraph::V(classifier@classification_tree)[suppressWarnings(.outnei(v))]$name

if(length(child_cell_types) == 0) next

Expand Down
1 change: 1 addition & 0 deletions garnett.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 42c81c7c-1e5c-4954-abb9-81f863ae13f1

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down
55 changes: 29 additions & 26 deletions tests/testthat/_snaps/utils/basic-marker-plot-change-amb.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 349c1f8

Please sign in to comment.