cumc / xqtl-protocol

Molecular QTL analysis protocol developed by ADSP Functional Genomics Consortium
https://cumc.github.io/xqtl-protocol/
MIT License
38 stars 42 forks source link

update cis workhorse #878

Closed rfeng2023 closed 6 months ago

rfeng2023 commented 6 months ago

the script is reporting error

ERROR: File contains parsing errors: [line 327]: Invalid f-string "), region_name=region_name) return (res) }

fitted = list() condition_names = vector() empty_elements = vector() r = 1 while (r<=length(fdat$residual_Y)) { dropped_samples = list(X=fdat$dropped_sample$dropped_samples_X[[r]], y=fdat$dropped_sample$dropped_samples_Y[[r]], covar=fdat$dropped_sample$dropped_samples_covar[[r]]) if (ncol(fdat$residual_Y[[r]]) == 1) { condition_names = c(condition_names, names(fdat$residual_Y)[r]) } else { new_names = colnames(fdat$residual_Y[[r]]) if (is.null(new_names)) {

column names does not exist, create generic names instead

      new_names = 1:ncol(fdat$residual_Y[[r]])
  }
  new_names = paste(names(fdat$residual_Y)[r], new_names, sep="_") # DLPFC_iso1 DLPFC_iso2
  condition_names = c(condition_names, new_names) # ACC DLPFC_iso1 DLPFC_iso2

} results <- lapply(1:ncol(fdat$residual_Y[[r]]), function(i) run_univariate_pipeline(fdat$residual_X[[r]], fdat$residual_Y[[r]][,i,drop=FALSE], fdat$residual_X_scalar[[r]], if (fdat$residual_Y_scalar[[r]] == 1) 1 else fdat$residual_Y_scalar[[r]][,i,drop=FALSE], fdat$maf[[r]], dropped_samples, pip_cutoff_to_skip = c(${",".join(['%s' % x for x in skip_analysis_pip_cutoff]})[r])) Update to accurately track empty results empty_indices <- which(sapply(results, function(x) is.list(x) && length(x) == 0)) empty_elements <- c(empty_elements, empty_indices + length(fitted)) # Adjust the indices based on already added results

fitted = c(fitted, results) original data no longer relevant, set to NA to release memory fdat$residual_X[[r]] <- NA fdat$residual_Y[[r]] <- NA r = r + 1 } Correctly assign names to non-empty results Assign names to fitted excluding empty results fitted_non_empty <- fitted[-empty_elements] # Remove empty elements names(fitted_non_empty) <- condition_names[-empty_elements]

message(length(empty_elements), " out of ", length(fitted), " results are thrown away because they are empty") saveRDS(list("${_meta_info[2]}" = fitted_non_empty), ${_output:ar}, compress='xz')

: invalid expression

which is not from this commit, and I don't know what does that mean... I tested region names with a separate cell which works well.

review-notebook-app[bot] commented 6 months ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

gaow commented 6 months ago

@rfeng2023 I accepted partially your changes, see here:

https://github.com/cumc/xqtl-pipeline/commit/b027f8a376d8f813894e95b3e3a4192fc0ade9b2

However as I indicated in our slack conversation, I don't like how you recover tuple from the strings. My suggestion was this:

image

please try that suggestion. Please first sync the repo so you get the updates first -- file names are also changed.

gaow commented 6 months ago

which is not from this commit, and I don't know what does that mean...

sorry my bad -- fixed here: https://github.com/cumc/xqtl-pipeline/commit/c83e62c3f67aef6d695bfc2bb34434fc10976a8d