Skip to content

Bug: camera raises IndexError with 3-column design and non-unit contrast #5

@robjelier-1

Description

@robjelier-1

Bug: camera raises IndexError with 3-column design and non-unit contrast

Version: latest (pip)

Description:
Calling camera with a 3-column design matrix and a contrast vector of length 3 raises an IndexError inside _camera_default.

Minimal reproducible example:

import numpy as np
import edgepython as ep

counts = np.random.poisson(lam=10, size=(1000, 9))
group = np.array(['U'] * 3 + ['D'] * 3 + ['L'] * 3)
design = np.column_stack([
    np.ones(9),
    (group == 'D').astype(float),
    (group == 'L').astype(float)
])
y = ep.make_dgelist(counts=counts, group=group)
y = ep.calc_norm_factors(y)
y = ep.estimate_disp(y, design=design)

index = {'set1': list(range(50))}
res = ep.camera(y, index=index, design=design, contrast=np.array([0, 0.5, 0.5]))

Traceback:

File .../edgepython/gene_sets.py:295, in _camera_default
    if R_reduced[p - 1, p - 1] < 0:
IndexError: index 2 is out of bounds for axis 0 with size 1

Root cause (suspected):
In _camera_default, the design matrix appears to be reduced to a single column before the QR decomposition, so R_reduced is 1×1. With a 3-column design, p-1 = 2 is then out of bounds.

Expected behavior:
camera should handle a multi-column design with a non-unit contrast vector, consistent with the behavior of camera.DGEList in edgeR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions