Skip to content

Conversation

@juli-p
Copy link
Collaborator

@juli-p juli-p commented Nov 13, 2025

Description of the bug

The bug occurs when calling the package's function sponge(...) with the optional parameter gene.combinations.
The function fails as soon as the data.frame given to gene.combinations contains genes in one of the columns multiple times, if the number of distinct values in one column is not a multiple of the other.

Error message:

Error in data.frame(which(all_genes %in% gene.combinations$geneA), which(all_genes %in%  : 
  arguments imply differing number of rows: 4, 10

Expected behavior

Using the same gene name multiple times in the data.frame gene.combinations should be allowed because each gene can potentially interact with multiple other genes and one might be interested in all those interactions.

Minimal example to reproduce the error

library(SPONGE)

# generating synthetic example data
samples = paste0("sample", 1:10)
genes = paste0("gene", 1:20)
mirnas = paste0("mir", 1:5)

set.seed(42)

gene_expr <- matrix(
    rnorm(length(genes) * length(samples)),
    ncol=length(genes),
    nrow=length(samples),
    dimnames = list(samples, genes))
mir_expr <- matrix(
    rnorm(length(mirnas) * length(samples)),
    nrow=length(samples),
    ncol=length(mirnas),
    dimnames = list(samples, mirnas))

mir_interactions <- lapply(genes, function(gene) {
    mirna_sample <- sample(mirnas, size=sample(1:length(mirnas), 1))
    data.frame(
        mirna = mirna_sample,
        coefficient = runif(length(mirna_sample), min=-0.3, max=-0.05),
        stringsAsFactors = FALSE)
})
names(mir_interactions) <- genes

# create gene.combinations in such way, that first column contains some gene names multiple times and the number of distinct genes in column 1 is not a multiple of the number of genes in column 2
gene.combinations <- data.frame(
    geneA = c(rep(genes[1:3], times=3), genes[4]),
    geneB = genes[11:20]
)

# call the package's function sponge(...) which results in the error in the current version of SPONGE
sponge(
    gene_expr=gene_expr,
    mir_expr=mir_expr,
    mir_interactions=mir_interactions,
    gene.combinations=gene.combinations,
    log.level="INFO"
)

@juli-p juli-p added the bug label Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants