Skip to content

compute_covet(): log1p-transformed data incorrectly detected as raw counts, causing double log-transformation #90

Description

@NoeCoursi

Hello!

Thank you for developing ENVI and this new promising approach to spatial transcriptomics.

While integrating COVET into a pipeline, I came across what looks like an edge case in compute_covet() and wanted to flag it.

In line 400 of utils.py, the heuristic used to detect whether spatial_data.X is already log-transformed relies on checking whether the minimum value is negative:

if spatial_data.X.min() < 0:
    # Data is already log-transformed
    print("Using expression data from X (appears to be log-transformed)")
    ...
else:
    print("Log-transforming expression data from X")
    exp_data = np.log(spatial_data[:, CovGenes].X + 1)

As far as I understand, this transformation should not produce values below 0. However, I believe that using a log1p transformation is quite standard in single-cell and spatial transcriptomics (e.g., sc.pp.log1p()). Notably, the function itself creates log1p-transformed layers (lines 364 and 406) using np.log(X + 1).

Although this is not a critical bug, and the print statement does indicate which branch is taken, I feel like the message "Log-transforming expression data from X" might not raise suspicion if the user assumes the detection is reliable.

I'm not sure how much this affects COVET outputs, but I wanted to bring it to your attention.

Maybe an integer detection like np.all(np.mod(X, 1) == 0) or an additional parameter could help avoid this ambiguity.

Hope this help !

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