Repository navigation
PERCEPTIONx v0.4.0 - #3
Merged
Merged
Conversation
- adopt cli/lifecycle tooling - import cli as messager
- convert internal data manipulation in annotate/prepare_data to data.table - move glmnet/randomForest to Suggests, add data.table to Imports - export perception_depmap_drugs/perception_fda_approved_drugs - add Yuxi Yang as contributor in DESCRIPTION - ignore *.qs2 and README.Rmd build artifacts
R cmd checking
- train_models() defaults to model_type = 'glmnet', and caret's glmnet model declares glmnet/Matrix at runtime. Moving them to Suggests makes the default path fail for users without those packages. - as.data.table() does not copy: the comment above the assignment promises a copy the code never made. Add an explicit copy() (also covers data.table < 1.15).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
规模:78 个文件,+10521 / −5767 行
任务清单见#2
1. 版本与依赖调整(
DESCRIPTION、NAMESPACE)person()改为c(...),新增 Yuxi Yang(ctb, ORCID 0009-0006-1329-1224)cli、lifecycle、data.tableglmnet、randomForest(→ Suggests)spelling、WGCNA、matrixStats、kableExtra(另收纳glmnet/randomForest)Language: en-US、Config/roxygen2/version: 8.1.0,移除RoxygenNoteimportFrom(ggplot2/stats/...),改为全限定调用;仅保留importFrom(data.table, %chin% , := , .N , .SD)+importFrom(rlang, .data)净效果:依赖收敛为「核心 4 个」,其余改为可选依赖 + 运行时检查。
2. 内部实现迁移到
data.table涉及
R/annotate.R、R/load.R、R/predict.R、R/train.R:prepare_data()/annotate_clones()的patient_mapping、cell_clone_map改由data.table::data.table()构建counts <- map_dt[, list(n_cells = .N), by = list(patient, clone_key)]+dcast+setnames+setcolorder取代循环/sapply:=、%chin%、fifelse()、.SD等语法;clone_viability_matrix、clone_counts、abundance统一as.data.table()归一化data.frame(如build_clone_counts仍返回 data.frame,因predict_patients()使用clone_counts[i, cols]的 data.frame 语义)count_row_NAs()由apply(df, 1, ...)改为rowSums(is.na(df))(性能优化)3. CLI 提示与现代化报错(最大类改动,约 150+ 处)
stop(...)→cli::cli_abort(c(x = ..., i = ...)),带可操作的修复建议(如"重新安装包")cli::cli_progress_step()/cli_progress_done()、cli::cli_alert_info/success/warning、cli_h2()/cli_ul()prepare_data():重写为[1/5] 聚类 → [2/5] 患者映射 → [3/5] 克隆级均值 → [4/5] 秩归一化 → [5/5] 丰度表五步式输出 + "Preparation complete" 汇总train_models():{i}/{length(drug_list)} Processing: {drug},并给出 "Skipping X - feature ranking failed / drug not found / all model builds failed" 的分级告警run_perception_app():stop()→rlang::check_installed(),缺失依赖一次性列出run_seurat_pipeline():标记lifecycle::deprecate_soft("0.3.1", ...)4. 可选依赖的运行时降级(新增健壮性)
WGCNAR/utils_cortest.R:86、R/train.R:256WGCNA::cor(..., use="pairwise.complete.obs", nThreads=)否则回退stats::cormatrixStatsR/predict.R:616-631rowMins/rowMaxs/rowMedians否则回退apply(...)kableExtraR/train.R:852kable()否则print()SeuratR/annotate.Rrlang::check_installed("Seurat", "for clone annotation.")5. 下载与镜像逻辑增强(
R/load.R)download_with_mirrors()由位置参数签名改为多行具名签名,新增:retries重试循环 +timeout_seconds(模型 30s、DepMap 300s)expected_size,按百分比提示后重试)speed_threshold,KB/s 提示"考虑换镜像")add_mirrors()增加"last"追加模式与"全部镜像已存在"短路提示6. 绘图(
R/plot.R)theme_perception()重做:显式白色panel/plot/legend背景、panel.grid.minor = element_blank()、轴/标题/图例继承字号(rel(0.85)等)、plot.margin、图例 key 尺寸ggplot2::函数改为全限定调用(配合 NAMESPACE 精简)cli::cli_abort()/cli::cli_alert_info()输入校验与提示7. 新增导出对象(数据目录)
三个药物清单从"内部常量"转为带文档的导出对象(
R/drugs.R):perception_depmap_drugsperception_fda_approved_drugsperception_all_drugs配套:新增
man/perception_*_drugs.Rd,_pkgdown.ymlreference 索引加入三者。注意:
R/drugs.R的 −2009/+... 里大部分是向量排版变化——改为# fmt:table+ 四列对齐(air的表格格式),字符串内容本身未变。8. 包启动信息(新文件
R/PERCEPTIONx-package.R)"_PACKAGE"包级 roxygen 文档(含 License / 链接).onLoad():cli::cli_progress_step("Loading {pkg} v{version}"),.onAttach()收尾startup_message_allowed():用packageStartupMessage探针 +withRestarts(muffleMessage=)判断是否允许输出启动信息(避免在suppressMessages()场景打扰)9. 工程化与文档
air.toml(新增)R/plot.R、inst/shiny/**、dev/**、tools/**大量改动仅为换行/缩进,无功能变化jarl.toml(新增)extend-select = ["TESTTHAT"]、exclude = ["R/vendor-*.R"]、check-roxygen = trueREADME.Rmd(新增,+210)README.md为产物(.Rbuildignore已排除^README\.Rmd$);README.md表格与段落被格式化重整tests/spelling.R+inst/WORDLIST(+100).Rbuildignoreair.toml、jarl.toml、.vscode、*.qs2、README.Rmd、test_pipeline_output、test_pipeline_v2_output.gitignore*.qs2、pipeline 输出目录.github/(新增)workflows/feishu.yaml(飞书 webhook 通知,监听 main/devel 的 PR/push 等 30+ 事件)、CODE_OF_CONDUCT.md、CONTRIBUTING.md、SUPPORT.md、ISSUE_TEMPLATE/issue_template.md、.github/.gitignoreman/*.Rd@param描述放宽为 "Matrix, data.frame, or data.table",新增 3 个数据集 Rd + 包级 Rd10.
dev/与tools/脚本仅格式化重排为主;
dev/bench_girafe.R、dev/time_demo.R、tools/test_pipeline*.R有参数/流程微调(benchmark 与 e2e 脚本适配新签名)。兼容性提示
download_with_mirrors()(内部函数)签名已重构,若有下游调用需同步。glmnet/randomForest已从 Imports 移到 Suggests——用户若未安装,train_models(model_type="glmnet")会通过 caret 间接失败;发布说明中建议提示安装。data.table语法,NAMESPACE的importFrom(data.table, ...)必须保留,否则cedta()判定失败会导致[.data.table退化为[.data.frame并报object '.N' not found。air批量格式化产生的纯空白变更,代码评审时可优先用git diff -w过滤。