Skip to content

Example userScript.R fails at generateRawAlignments() #59

@sumiyaabdi

Description

@sumiyaabdi

The test example code throws an error here. Maybe because in R/main.R this line returns a pandas dataframe which can't be read by nrow in the following lines.

Here is the error:

> output_all <- stringDF %>%
+     generateRawAlignments(
+         regimens = regimens,
+         g = 0.4,
+         Tfac = 0.4,
+         method = "PropDiff",
+         verbose = 0
+     )
Processing patients:   0%|          | 0/4 [00:00<?, ?it/s]/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/ARTEMIS/cython/main.py:26: ChainedAssignmentError: A value is being set on a copy of a DataFrame or Series through chained assignment.
Such chained assignment never works to update the original DataFrame or Series, because the intermediate object on which we are setting values always behaves as a copy (due to Copy-on-Write).

Try using '.loc[row_indexer, col_indexer] = value' instead, to perform the assignment in a single step.

See the documentation for a more detailed explanation: [https://pandas.pydata.org/pandas-docs/stable/user_guide/copy_on_write.html#chained-assignment](vscode-file://vscode-app/Applications/Positron.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html#)
  return align_patients_regimens_fast(
Processing patients: 100%|██████████| 4/4 [00:00<00:00, 37.65it/s]
Error in `if (nrow(output) == 0) ...`:
! argument is of length zero
Hide Traceback1. ├─stringDF %>% ... at [packages/ARTEMIS/userScript.R:59:1](vscode-file://vscode-app/Applications/Positron.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html#)
 2. └─ARTEMIS::generateRawAlignments(...)

Some version info:

INSTALLED VERSIONS
------------------
python                : 3.14.3
python-bits           : 64
OS                    : Darwin
OS-release            : 23.6.0
Version               : Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000
machine               : arm64
processor             : arm
byteorder             : little
LC_ALL                : None
LANG                  : en_US.UTF-8
LOCALE                : None.UTF-8

pandas                : 3.0.0
numpy                 : 2.4.2
dateutil              : 2.9.0.post0
pip                   : 26.0.1
Cython                : 3.2.4`

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