🔍 API报错解决方案大全

程序员必备 · 错误查询手册 · AI智能解答

🏠 返回首页

1,290

已收录的API报错解决方案

> library(maSigPro) > library(readr) > > # 设置工作目录 > setwd("D:/ANorth/muilt/呼吸多组学-陈宵/Analysis-lym/1.单组学分析/转录组/4时序分析") > > # 读取数据 > gene_matrix <- read_delim("geneMatrix_normalized_log2cpm.txt", delim = "\t", col_names = TRUE) Rows: 13692 Columns: 37 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "\t" chr (1): symble dbl (36): 24hC1, 5DC1, 6hC1, 72hC1, 24hC2, 5DC2, 6hC2, 72hC2, 24hC3, 5DC3, 6hC3, 72hC3, 24hH1, 5DH... ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. > meta_data <- read_csv("meta_all.csv") Rows: 36 Columns: 6 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (1): sample dbl (5): time, Ctrl, Low, High, replicate ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. > > # 设置行名为基因名 > rownames(gene_matrix) <- gene_matrix$symble > gene_matrix <- gene_matrix[, -1] # 去掉第一列的基因名 > > # 确保meta_data的行名是样本名 > rownames(meta_data) <- meta_data$sample > > # 构建设计矩阵 > # 根据您的实验设计,您有4个时间点和3个处理组(Control, Low, High) > # 构建设计矩阵时,需要指定时间列、重复列和实验组列 > design <- make.design.matrix(meta_data, degree = 3, time.col = 2, repl.col = 6, group.cols = c(3, 4, 5)) 错误于Ops.data.frame(edesign[, time.col]^i, edesign[, dummy.cols]): ‘*’ 仅针对大小相等的数据框定义

2025年09月06日

> ## 1 读入并对齐 ------------------------------------------------------------ > mat <- read_csv("geneMatrix_Control_normalized_log2cpm.csv") %>% + column_to_rownames("symble") %>% as.matrix() Rows: 13692 Columns: 13 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (1): symble dbl (12): 6hC1, 6hC2, 6hC3, 24hC1, 24hC2, 24hC3, 72hC1, 72hC2, 72hC3, 120hC1, 120hC2, 120hC3 ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. > meta <- read_csv("meta_Control.csv") %>% arrange(symble) Rows: 12 Columns: 4 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (2): symble, group dbl (2): time, replicate ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. > > # 确保 mat 的列名和 meta 的 sample_name 列完全一致 > if (!all(colnames(mat) == meta$sample_name)) { + cat("列名不一致,正在对齐...\n") + mat <- mat[, meta$sample_name] # 重新对齐列顺序 + stopifnot(all(colnames(mat) == meta$sample_name)) # 再次检查 + } > > ## 2 构建 design 矩阵 ----------------------------------------------------- > design <- data.frame( + time = meta$time, + replicate = factor(meta$replicate) + ) > rownames(design) <- meta$sample_name > > ## 3 maSigPro 两步回归 ----------------------------------------------------- > fit <- p.vector(mat, design, Q = 0.05, "gaussian", MT.adjust = "BH") 错误于dat[, as.character(rownames(dis))]: 下标出界

2025年09月06日

+ ## 6 可选:持续上调/下调基因 + coef <- tfit$sig.models + up <- rownames(coef)[coef$time > 0 & coef$time < 0.05 & is.na(coef$time2)] + down <- rownames(coef)[coef$time < 0 & coef$time < 0.05 & is.na(coef$time2)] + write_csv(tibble(gene = up), str_c(prefix, "_up_genes.csv")) + write_csv(tibble(gene = down), str_c(prefix, "_down_genes.csv")) + } ====== running Control ====== Rows: 13692 Columns: 13 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (1): symble dbl (12): 6hC1, 6hC2, 6hC3, 24hC1, 24hC2, 24hC3, 72hC1, 72hC2, 72hC3, 120hC1, 120hC2, 120hC3 ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. Rows: 12 Columns: 4 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (2): sample, group dbl (2): time, replicate ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. [1] "fitting gene 100 out of 13692" [1] "fitting gene 200 out of 13692" [1] "fitting gene 300 out of 13692" [1] "fitting gene 400 out of 13692" [1] "fitting gene 500 out of 13692" [1] "fitting gene 600 out of 13692" [1] "fitting gene 700 out of 13692" [1] "fitting gene 800 out of 13692" [1] "fitting gene 900 out of 13692" [1] "fitting gene 1000 out of 13692" [1] "fitting gene 1100 out of 13692" [1] "fitting gene 1200 out of 13692" [1] "fitting gene 1300 out of 13692" [1] "fitting gene 1400 out of 13692" [1] "fitting gene 1500 out of 13692" [1] "fitting gene 1600 out of 13692" [1] "fitting gene 1700 out of 13692" [1] "fitting gene 1800 out of 13692" [1] "fitting gene 1900 out of 13692" [1] "fitting gene 2000 out of 13692" [1] "fitting gene 2100 out of 13692" [1] "fitting gene 2200 out of 13692" [1] "fitting gene 2300 out of 13692" [1] "fitting gene 2400 out of 13692" [1] "fitting gene 2500 out of 13692" [1] "fitting gene 2600 out of 13692" [1] "fitting gene 2700 out of 13692" [1] "fitting gene 2800 out of 13692" [1] "fitting gene 2900 out of 13692" [1] "fitting gene 3000 out of 13692" [1] "fitting gene 3100 out of 13692" [1] "fitting gene 3200 out of 13692" [1] "fitting gene 3300 out of 13692" [1] "fitting gene 3400 out of 13692" [1] "fitting gene 3500 out of 13692" [1] "fitting gene 3600 out of 13692" [1] "fitting gene 3700 out of 13692" [1] "fitting gene 3800 out of 13692" [1] "fitting gene 3900 out of 13692" [1] "fitting gene 4000 out of 13692" [1] "fitting gene 4100 out of 13692" [1] "fitting gene 4200 out of 13692" [1] "fitting gene 4300 out of 13692" [1] "fitting gene 4400 out of 13692" [1] "fitting gene 4500 out of 13692" [1] "fitting gene 4600 out of 13692" [1] "fitting gene 4700 out of 13692" [1] "fitting gene 4800 out of 13692" [1] "fitting gene 4900 out of 13692" [1] "fitting gene 5000 out of 13692" [1] "fitting gene 5100 out of 13692" [1] "fitting gene 5200 out of 13692" [1] "fitting gene 5300 out of 13692" [1] "fitting gene 5400 out of 13692" [1] "fitting gene 5500 out of 13692" [1] "fitting gene 5600 out of 13692" [1] "fitting gene 5700 out of 13692" [1] "fitting gene 5800 out of 13692" [1] "fitting gene 5900 out of 13692" [1] "fitting gene 6000 out of 13692" [1] "fitting gene 6100 out of 13692" [1] "fitting gene 6200 out of 13692" [1] "fitting gene 6300 out of 13692" [1] "fitting gene 6400 out of 13692" [1] "fitting gene 6500 out of 13692" [1] "fitting gene 6600 out of 13692" [1] "fitting gene 6700 out of 13692" [1] "fitting gene 6800 out of 13692" [1] "fitting gene 6900 out of 13692" [1] "fitting gene 7000 out of 13692" [1] "fitting gene 7100 out of 13692" [1] "fitting gene 7200 out of 13692" [1] "fitting gene 7300 out of 13692" [1] "fitting gene 7400 out of 13692" [1] "fitting gene 7500 out of 13692" [1] "fitting gene 7600 out of 13692" [1] "fitting gene 7700 out of 13692" [1] "fitting gene 7800 out of 13692" [1] "fitting gene 7900 out of 13692" [1] "fitting gene 8000 out of 13692" [1] "fitting gene 8100 out of 13692" [1] "fitting gene 8200 out of 13692" [1] "fitting gene 8300 out of 13692" [1] "fitting gene 8400 out of 13692" [1] "fitting gene 8500 out of 13692" [1] "fitting gene 8600 out of 13692" [1] "fitting gene 8700 out of 13692" [1] "fitting gene 8800 out of 13692" [1] "fitting gene 8900 out of 13692" [1] "fitting gene 9000 out of 13692" [1] "fitting gene 9100 out of 13692" [1] "fitting gene 9200 out of 13692" [1] "fitting gene 9300 out of 13692" [1] "fitting gene 9400 out of 13692" [1] "fitting gene 9500 out of 13692" [1] "fitting gene 9600 out of 13692" [1] "fitting gene 9700 out of 13692" [1] "fitting gene 9800 out of 13692" [1] "fitting gene 9900 out of 13692" [1] "fitting gene 10000 out of 13692" [1] "fitting gene 10100 out of 13692" [1] "fitting gene 10200 out of 13692" [1] "fitting gene 10300 out of 13692" [1] "fitting gene 10400 out of 13692" [1] "fitting gene 10500 out of 13692" [1] "fitting gene 10600 out of 13692" [1] "fitting gene 10700 out of 13692" [1] "fitting gene 10800 out of 13692" [1] "fitting gene 10900 out of 13692" [1] "fitting gene 11000 out of 13692" [1] "fitting gene 11100 out of 13692" [1] "fitting gene 11200 out of 13692" [1] "fitting gene 11300 out of 13692" [1] "fitting gene 11400 out of 13692" [1] "fitting gene 11500 out of 13692" [1] "fitting gene 11600 out of 13692" [1] "fitting gene 11700 out of 13692" [1] "fitting gene 11800 out of 13692" [1] "fitting gene 11900 out of 13692" [1] "fitting gene 12000 out of 13692" [1] "fitting gene 12100 out of 13692" [1] "fitting gene 12200 out of 13692" [1] "fitting gene 12300 out of 13692" [1] "fitting gene 12400 out of 13692" [1] "fitting gene 12500 out of 13692" [1] "fitting gene 12600 out of 13692" [1] "fitting gene 12700 out of 13692" [1] "fitting gene 12800 out of 13692" [1] "fitting gene 12900 out of 13692" [1] "fitting gene 13000 out of 13692" [1] "fitting gene 13100 out of 13692" [1] "fitting gene 13200 out of 13692" [1] "fitting gene 13300 out of 13692" [1] "fitting gene 13400 out of 13692" [1] "fitting gene 13500 out of 13692" [1] "fitting gene 13600 out of 13692" 错误于match.arg(method): 'arg' should be one of “holm”, “hochberg”, “hommel”, “bonferroni”, “BH”, “BY”, “fdr”, “none”

2025年09月06日

+ ## 6 可选:持续上调/下调基因 + coef <- tfit$sig.models + up <- rownames(coef)[coef$time > 0 & coef$time < 0.05 & is.na(coef$time2)] + down <- rownames(coef)[coef$time < 0 & coef$time < 0.05 & is.na(coef$time2)] + write_csv(tibble(gene = up), str_c(prefix, "_up_genes.csv")) + write_csv(tibble(gene = down), str_c(prefix, "_down_genes.csv")) + } ====== running Control ====== Rows: 13692 Columns: 13 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (1): symble dbl (12): 6hC1, 6hC2, 6hC3, 24hC1, 24hC2, 24hC3, 72hC1, 72hC2, 72hC3, 120hC1, 120hC2, 120hC3 ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. Rows: 12 Columns: 4 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (2): sample, group dbl (2): time, replicate ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. [1] "fitting gene 100 out of 13692" [1] "fitting gene 200 out of 13692" [1] "fitting gene 300 out of 13692" [1] "fitting gene 400 out of 13692" [1] "fitting gene 500 out of 13692" [1] "fitting gene 600 out of 13692" [1] "fitting gene 700 out of 13692" [1] "fitting gene 800 out of 13692" [1] "fitting gene 900 out of 13692" [1] "fitting gene 1000 out of 13692" [1] "fitting gene 1100 out of 13692" [1] "fitting gene 1200 out of 13692" [1] "fitting gene 1300 out of 13692" [1] "fitting gene 1400 out of 13692" [1] "fitting gene 1500 out of 13692" [1] "fitting gene 1600 out of 13692" [1] "fitting gene 1700 out of 13692" [1] "fitting gene 1800 out of 13692" [1] "fitting gene 1900 out of 13692" [1] "fitting gene 2000 out of 13692" [1] "fitting gene 2100 out of 13692" [1] "fitting gene 2200 out of 13692" [1] "fitting gene 2300 out of 13692" [1] "fitting gene 2400 out of 13692" [1] "fitting gene 2500 out of 13692" [1] "fitting gene 2600 out of 13692" [1] "fitting gene 2700 out of 13692" [1] "fitting gene 2800 out of 13692" [1] "fitting gene 2900 out of 13692" [1] "fitting gene 3000 out of 13692" [1] "fitting gene 3100 out of 13692" [1] "fitting gene 3200 out of 13692" [1] "fitting gene 3300 out of 13692" [1] "fitting gene 3400 out of 13692" [1] "fitting gene 3500 out of 13692" [1] "fitting gene 3600 out of 13692" [1] "fitting gene 3700 out of 13692" [1] "fitting gene 3800 out of 13692" [1] "fitting gene 3900 out of 13692" [1] "fitting gene 4000 out of 13692" [1] "fitting gene 4100 out of 13692" [1] "fitting gene 4200 out of 13692" [1] "fitting gene 4300 out of 13692" [1] "fitting gene 4400 out of 13692" [1] "fitting gene 4500 out of 13692" [1] "fitting gene 4600 out of 13692" [1] "fitting gene 4700 out of 13692" [1] "fitting gene 4800 out of 13692" [1] "fitting gene 4900 out of 13692" [1] "fitting gene 5000 out of 13692" [1] "fitting gene 5100 out of 13692" [1] "fitting gene 5200 out of 13692" [1] "fitting gene 5300 out of 13692" [1] "fitting gene 5400 out of 13692" [1] "fitting gene 5500 out of 13692" [1] "fitting gene 5600 out of 13692" [1] "fitting gene 5700 out of 13692" [1] "fitting gene 5800 out of 13692" [1] "fitting gene 5900 out of 13692" [1] "fitting gene 6000 out of 13692" [1] "fitting gene 6100 out of 13692" [1] "fitting gene 6200 out of 13692" [1] "fitting gene 6300 out of 13692" [1] "fitting gene 6400 out of 13692" [1] "fitting gene 6500 out of 13692" [1] "fitting gene 6600 out of 13692" [1] "fitting gene 6700 out of 13692" [1] "fitting gene 6800 out of 13692" [1] "fitting gene 6900 out of 13692" [1] "fitting gene 7000 out of 13692" [1] "fitting gene 7100 out of 13692" [1] "fitting gene 7200 out of 13692" [1] "fitting gene 7300 out of 13692" [1] "fitting gene 7400 out of 13692" [1] "fitting gene 7500 out of 13692" [1] "fitting gene 7600 out of 13692" [1] "fitting gene 7700 out of 13692" [1] "fitting gene 7800 out of 13692" [1] "fitting gene 7900 out of 13692" [1] "fitting gene 8000 out of 13692" [1] "fitting gene 8100 out of 13692" [1] "fitting gene 8200 out of 13692" [1] "fitting gene 8300 out of 13692" [1] "fitting gene 8400 out of 13692" [1] "fitting gene 8500 out of 13692" [1] "fitting gene 8600 out of 13692" [1] "fitting gene 8700 out of 13692" [1] "fitting gene 8800 out of 13692" [1] "fitting gene 8900 out of 13692" [1] "fitting gene 9000 out of 13692" [1] "fitting gene 9100 out of 13692" [1] "fitting gene 9200 out of 13692" [1] "fitting gene 9300 out of 13692" [1] "fitting gene 9400 out of 13692" [1] "fitting gene 9500 out of 13692" [1] "fitting gene 9600 out of 13692" [1] "fitting gene 9700 out of 13692" [1] "fitting gene 9800 out of 13692" [1] "fitting gene 9900 out of 13692" [1] "fitting gene 10000 out of 13692" [1] "fitting gene 10100 out of 13692" [1] "fitting gene 10200 out of 13692" [1] "fitting gene 10300 out of 13692" [1] "fitting gene 10400 out of 13692" [1] "fitting gene 10500 out of 13692" [1] "fitting gene 10600 out of 13692" [1] "fitting gene 10700 out of 13692" [1] "fitting gene 10800 out of 13692" [1] "fitting gene 10900 out of 13692" [1] "fitting gene 11000 out of 13692" [1] "fitting gene 11100 out of 13692" [1] "fitting gene 11200 out of 13692" [1] "fitting gene 11300 out of 13692" [1] "fitting gene 11400 out of 13692" [1] "fitting gene 11500 out of 13692" [1] "fitting gene 11600 out of 13692" [1] "fitting gene 11700 out of 13692" [1] "fitting gene 11800 out of 13692" [1] "fitting gene 11900 out of 13692" [1] "fitting gene 12000 out of 13692" [1] "fitting gene 12100 out of 13692" [1] "fitting gene 12200 out of 13692" [1] "fitting gene 12300 out of 13692" [1] "fitting gene 12400 out of 13692" [1] "fitting gene 12500 out of 13692" [1] "fitting gene 12600 out of 13692" [1] "fitting gene 12700 out of 13692" [1] "fitting gene 12800 out of 13692" [1] "fitting gene 12900 out of 13692" [1] "fitting gene 13000 out of 13692" [1] "fitting gene 13100 out of 13692" [1] "fitting gene 13200 out of 13692" [1] "fitting gene 13300 out of 13692" [1] "fitting gene 13400 out of 13692" [1] "fitting gene 13500 out of 13692" [1] "fitting gene 13600 out of 13692" 错误于match.arg(method): 'arg' should be one of “holm”, “hochberg”, “hommel”, “bonferroni”, “BH”, “BY”, “fdr”, “none”

2025年09月06日

> > library(tidyverse) > library(maSigPro) > library(readr) > > setwd("D:/ANorth/muilt/呼吸多组学-陈宵/Analysis-lym/1.单组学分析/转录组/4时序分析") > dir.create("maSigPro_results", showWarnings = FALSE) > > groups <- c("Control", "Low", "High") > > for (g in groups) { + cat("\n====== running", g, "======\n") + + ## 1 读入并对齐 ------------------------------------------------------------ + mat <- read_csv(str_c("geneMatrix_", g, "_normalized_log2cpm.csv")) %>% + column_to_rownames("symble") %>% as.matrix() + meta <- read_csv(str_c("meta_", g, ".csv")) %>% arrange(sample) + mat <- mat[, meta$sample] # 严格对齐列顺序 + + ## 2 design ≥2 列,replicate 为因子 + design <- data.frame( + time = meta$time, + replicate = factor(meta$replicate) + ) + rownames(design) <- meta$sample + + ## 3 maSigPro 两步回归 ----------------------------------------------------- + fit <- p.vector(mat, design, Q = 0.05, "gaussian") # 修正:直接传递 "gaussian" + tfit <- T.fit(fit, + step.method = "two.ways.backward", + alfa = 0.05, + adjust = "fdr") # 使用 fdr 校正 + sig <- get.siggenes(tfit, rsq = 0.6) + + ## 4 写出结果 -------------------------------------------------------------- + prefix <- str_c("maSigPro_results/", g) + + write_csv(sig$sig.genes %>% as_tibble(rownames = "gene"), + str_c(prefix, "_sig_genes.csv")) + write_csv(tfit$sig.models %>% as_tibble(rownames = "gene"), + str_c(prefix, "_coef.csv")) + + ## 5 趋势图 + pdf(str_c(prefix, "_trends.pdf"), width = 8, height = 5) + plot(tfit, name = g, clustering = TRUE) + dev.off() + + ## 6 可选:持续上调/下调基因 + coef <- tfit$sig.models + up <- rownames(coef)[coef$time > 0 & coef$time < 0.05 & is.na(coef$time2)] + down <- rownames(coef)[coef$time < 0 & coef$time < 0.05 & is.na(coef$time2)] + write_csv(tibble(gene = up), str_c(prefix, "_up_genes.csv")) + write_csv(tibble(gene = down), str_c(prefix, "_down_genes.csv")) + } ====== running Control ====== Rows: 13692 Columns: 13 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (1): symble dbl (12): 6hC1, 6hC2, 6hC3, 24hC1, 24hC2, 24hC3, 72hC1, 72hC2, 72hC3, 120hC1, 120hC2, 120hC3 ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. Rows: 12 Columns: 4 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (2): sample, group dbl (2): time, replicate ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. [1] "fitting gene 100 out of 13692" [1] "fitting gene 200 out of 13692" [1] "fitting gene 300 out of 13692" [1] "fitting gene 400 out of 13692" [1] "fitting gene 500 out of 13692" [1] "fitting gene 600 out of 13692" [1] "fitting gene 700 out of 13692" [1] "fitting gene 800 out of 13692" [1] "fitting gene 900 out of 13692" [1] "fitting gene 1000 out of 13692" [1] "fitting gene 1100 out of 13692" [1] "fitting gene 1200 out of 13692" [1] "fitting gene 1300 out of 13692" [1] "fitting gene 1400 out of 13692" [1] "fitting gene 1500 out of 13692" [1] "fitting gene 1600 out of 13692" [1] "fitting gene 1700 out of 13692" [1] "fitting gene 1800 out of 13692" [1] "fitting gene 1900 out of 13692" [1] "fitting gene 2000 out of 13692" [1] "fitting gene 2100 out of 13692" [1] "fitting gene 2200 out of 13692" [1] "fitting gene 2300 out of 13692" [1] "fitting gene 2400 out of 13692" [1] "fitting gene 2500 out of 13692" [1] "fitting gene 2600 out of 13692" [1] "fitting gene 2700 out of 13692" [1] "fitting gene 2800 out of 13692" [1] "fitting gene 2900 out of 13692" [1] "fitting gene 3000 out of 13692" [1] "fitting gene 3100 out of 13692" [1] "fitting gene 3200 out of 13692" [1] "fitting gene 3300 out of 13692" [1] "fitting gene 3400 out of 13692" [1] "fitting gene 3500 out of 13692" [1] "fitting gene 3600 out of 13692" [1] "fitting gene 3700 out of 13692" [1] "fitting gene 3800 out of 13692" [1] "fitting gene 3900 out of 13692" [1] "fitting gene 4000 out of 13692" [1] "fitting gene 4100 out of 13692" [1] "fitting gene 4200 out of 13692" [1] "fitting gene 4300 out of 13692" [1] "fitting gene 4400 out of 13692" [1] "fitting gene 4500 out of 13692" [1] "fitting gene 4600 out of 13692" [1] "fitting gene 4700 out of 13692" [1] "fitting gene 4800 out of 13692" [1] "fitting gene 4900 out of 13692" [1] "fitting gene 5000 out of 13692" [1] "fitting gene 5100 out of 13692" [1] "fitting gene 5200 out of 13692" [1] "fitting gene 5300 out of 13692" [1] "fitting gene 5400 out of 13692" [1] "fitting gene 5500 out of 13692" [1] "fitting gene 5600 out of 13692" [1] "fitting gene 5700 out of 13692" [1] "fitting gene 5800 out of 13692" [1] "fitting gene 5900 out of 13692" [1] "fitting gene 6000 out of 13692" [1] "fitting gene 6100 out of 13692" [1] "fitting gene 6200 out of 13692" [1] "fitting gene 6300 out of 13692" [1] "fitting gene 6400 out of 13692" [1] "fitting gene 6500 out of 13692" [1] "fitting gene 6600 out of 13692" [1] "fitting gene 6700 out of 13692" [1] "fitting gene 6800 out of 13692" [1] "fitting gene 6900 out of 13692" [1] "fitting gene 7000 out of 13692" [1] "fitting gene 7100 out of 13692" [1] "fitting gene 7200 out of 13692" [1] "fitting gene 7300 out of 13692" [1] "fitting gene 7400 out of 13692" [1] "fitting gene 7500 out of 13692" [1] "fitting gene 7600 out of 13692" [1] "fitting gene 7700 out of 13692" [1] "fitting gene 7800 out of 13692" [1] "fitting gene 7900 out of 13692" [1] "fitting gene 8000 out of 13692" [1] "fitting gene 8100 out of 13692" [1] "fitting gene 8200 out of 13692" [1] "fitting gene 8300 out of 13692" [1] "fitting gene 8400 out of 13692" [1] "fitting gene 8500 out of 13692" [1] "fitting gene 8600 out of 13692" [1] "fitting gene 8700 out of 13692" [1] "fitting gene 8800 out of 13692" [1] "fitting gene 8900 out of 13692" [1] "fitting gene 9000 out of 13692" [1] "fitting gene 9100 out of 13692" [1] "fitting gene 9200 out of 13692" [1] "fitting gene 9300 out of 13692" [1] "fitting gene 9400 out of 13692" [1] "fitting gene 9500 out of 13692" [1] "fitting gene 9600 out of 13692" [1] "fitting gene 9700 out of 13692" [1] "fitting gene 9800 out of 13692" [1] "fitting gene 9900 out of 13692" [1] "fitting gene 10000 out of 13692" [1] "fitting gene 10100 out of 13692" [1] "fitting gene 10200 out of 13692" [1] "fitting gene 10300 out of 13692" [1] "fitting gene 10400 out of 13692" [1] "fitting gene 10500 out of 13692" [1] "fitting gene 10600 out of 13692" [1] "fitting gene 10700 out of 13692" [1] "fitting gene 10800 out of 13692" [1] "fitting gene 10900 out of 13692" [1] "fitting gene 11000 out of 13692" [1] "fitting gene 11100 out of 13692" [1] "fitting gene 11200 out of 13692" [1] "fitting gene 11300 out of 13692" [1] "fitting gene 11400 out of 13692" [1] "fitting gene 11500 out of 13692" [1] "fitting gene 11600 out of 13692" [1] "fitting gene 11700 out of 13692" [1] "fitting gene 11800 out of 13692" [1] "fitting gene 11900 out of 13692" [1] "fitting gene 12000 out of 13692" [1] "fitting gene 12100 out of 13692" [1] "fitting gene 12200 out of 13692" [1] "fitting gene 12300 out of 13692" [1] "fitting gene 12400 out of 13692" [1] "fitting gene 12500 out of 13692" [1] "fitting gene 12600 out of 13692" [1] "fitting gene 12700 out of 13692" [1] "fitting gene 12800 out of 13692" [1] "fitting gene 12900 out of 13692" [1] "fitting gene 13000 out of 13692" [1] "fitting gene 13100 out of 13692" [1] "fitting gene 13200 out of 13692" [1] "fitting gene 13300 out of 13692" [1] "fitting gene 13400 out of 13692" [1] "fitting gene 13500 out of 13692" [1] "fitting gene 13600 out of 13692" 错误于match.arg(method): 'arg' should be one of “holm”, “hochberg”, “hommel”, “bonferroni”, “BH”, “BY”, “fdr”, “none”

2025年09月06日

> #!/usr/bin/env Rscript > # 批量 maSigPro:Control / Low / High 三组分别跑(标准化 log2CPM) > # 工作目录:D:/ANorth/muilt/呼吸多组学-陈宵/Analysis-lym/1.单组学分析/转录组/4时序分析 > > library(tidyverse) > library(maSigPro) > library(readr) > > setwd("D:/ANorth/muilt/呼吸多组学-陈宵/Analysis-lym/1.单组学分析/转录组/4时序分析") > dir.create("maSigPro_results", showWarnings = FALSE) > > groups <- c("Control", "Low", "High") > > for (g in groups) { + cat("\n====== running", g, "======\n") + + ## 1 读入并对齐 ------------------------------------------------------------ + mat <- read_csv(str_c("geneMatrix_", g, "_normalized_log2cpm.csv")) %>% + column_to_rownames("symble") %>% as.matrix() + meta <- read_csv(str_c("meta_", g, ".csv")) %>% arrange(sample) + mat <- mat[, meta$sample] # 严格对齐列顺序 + + ## 2 design ≥2 列,replicate 为因子 + design <- data.frame( + time = meta$time, + replicate = factor(meta$replicate) + ) + rownames(design) <- meta$sample + + ## 3 maSigPro 两步回归 ----------------------------------------------------- + fit <- p.vector(mat, design, Q = 0.05, family = "gaussian") + tfit <- T.fit(fit, + step.method = "two.ways.backward", + alfa = 0.05, + adjust = "fdr") # 使用 fdr 校正 + sig <- get.siggenes(tfit, rsq = 0.6) + + ## 4 写出结果 -------------------------------------------------------------- + prefix <- str_c("maSigPro_results/", g) + + write_csv(sig$sig.genes %>% as_tibble(rownames = "gene"), + str_c(prefix, "_sig_genes.csv")) + write_csv(tfit$sig.models %>% as_tibble(rownames = "gene"), + str_c(prefix, "_coef.csv")) + + ## 5 趋势图 + pdf(str_c(prefix, "_trends.pdf"), width = 8, height = 5) + plot(tfit, name = g, clustering = TRUE) + dev.off() + + ## 6 可选:持续上调/下调基因 + coef <- tfit$sig.models + up <- rownames(coef)[coef$time > 0 & coef$time < 0.05 & is.na(coef$time2)] + down <- rownames(coef)[coef$time < 0 & coef$time < 0.05 & is.na(coef$time2)] + write_csv(tibble(gene = up), str_c(prefix, "_up_genes.csv")) + write_csv(tibble(gene = down), str_c(prefix, "_down_genes.csv")) + } ====== running Control ====== Rows: 13692 Columns: 13 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (1): symble dbl (12): 6hC1, 6hC2, 6hC3, 24hC1, 24hC2, 24hC3, 72hC1, 72hC2, 72hC3, 120hC1, 120hC2, 120hC3 ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. Rows: 12 Columns: 4 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (2): sample, group dbl (2): time, replicate ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. 错误于family$family: $ operator is invalid for atomic vectors

2025年09月06日

> library(tidyverse) > library(maSigPro) > setwd("D:/ANorth/muilt/呼吸多组学-陈宵/Analysis-lym/1.单组学分析/转录组/4时序分析") > > ## 1. 读入推文格式数据 --------------------------------------------------------- > counts <- read_csv("geneMatrix_Control_normalized_log2cpm.csv") %>% + column_to_rownames("symble") %>% as.matrix() Rows: 13692 Columns: 13 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (1): symble dbl (12): 6hC1, 6hC2, 6hC3, 24hC1, 24hC2, 24hC3, 72hC1, 72hC2, 72hC3, 120hC1, 120hC2, 120hC3 ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. > > ## 2. 构建推文同款 design(time + replicate_factor) > meta <- read_csv("meta_Control.csv") %>% arrange(sample) Rows: 12 Columns: 4 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (2): sample, group dbl (2): time, replicate ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. > design <- data.frame( + time = meta$time, + replicate = factor(meta$replicate) + ) > rownames(design) <- meta$sample > > ## 3. 严格对齐列顺序(推文没写,但必须) > counts <- counts[, meta$sample] > > ## 4. 推文两步回归 ------------------------------------------------------------- > fit <- p.vector(counts, design, Q = 0.05, "gaussian") [1] "fitting gene 100 out of 13692" [1] "fitting gene 200 out of 13692" [1] "fitting gene 300 out of 13692" [1] "fitting gene 400 out of 13692" [1] "fitting gene 500 out of 13692" [1] "fitting gene 600 out of 13692" [1] "fitting gene 700 out of 13692" [1] "fitting gene 800 out of 13692" [1] "fitting gene 900 out of 13692" [1] "fitting gene 1000 out of 13692" [1] "fitting gene 1100 out of 13692" [1] "fitting gene 1200 out of 13692" [1] "fitting gene 1300 out of 13692" [1] "fitting gene 1400 out of 13692" [1] "fitting gene 1500 out of 13692" [1] "fitting gene 1600 out of 13692" [1] "fitting gene 1700 out of 13692" [1] "fitting gene 1800 out of 13692" [1] "fitting gene 1900 out of 13692" [1] "fitting gene 2000 out of 13692" [1] "fitting gene 2100 out of 13692" [1] "fitting gene 2200 out of 13692" [1] "fitting gene 2300 out of 13692" [1] "fitting gene 2400 out of 13692" [1] "fitting gene 2500 out of 13692" [1] "fitting gene 2600 out of 13692" [1] "fitting gene 2700 out of 13692" [1] "fitting gene 2800 out of 13692" [1] "fitting gene 2900 out of 13692" [1] "fitting gene 3000 out of 13692" [1] "fitting gene 3100 out of 13692" [1] "fitting gene 3200 out of 13692" [1] "fitting gene 3300 out of 13692" [1] "fitting gene 3400 out of 13692" [1] "fitting gene 3500 out of 13692" [1] "fitting gene 3600 out of 13692" [1] "fitting gene 3700 out of 13692" [1] "fitting gene 3800 out of 13692" [1] "fitting gene 3900 out of 13692" [1] "fitting gene 4000 out of 13692" [1] "fitting gene 4100 out of 13692" [1] "fitting gene 4200 out of 13692" [1] "fitting gene 4300 out of 13692" [1] "fitting gene 4400 out of 13692" [1] "fitting gene 4500 out of 13692" [1] "fitting gene 4600 out of 13692" [1] "fitting gene 4700 out of 13692" [1] "fitting gene 4800 out of 13692" [1] "fitting gene 4900 out of 13692" [1] "fitting gene 5000 out of 13692" [1] "fitting gene 5100 out of 13692" [1] "fitting gene 5200 out of 13692" [1] "fitting gene 5300 out of 13692" [1] "fitting gene 5400 out of 13692" [1] "fitting gene 5500 out of 13692" [1] "fitting gene 5600 out of 13692" [1] "fitting gene 5700 out of 13692" [1] "fitting gene 5800 out of 13692" [1] "fitting gene 5900 out of 13692" [1] "fitting gene 6000 out of 13692" [1] "fitting gene 6100 out of 13692" [1] "fitting gene 6200 out of 13692" [1] "fitting gene 6300 out of 13692" [1] "fitting gene 6400 out of 13692" [1] "fitting gene 6500 out of 13692" [1] "fitting gene 6600 out of 13692" [1] "fitting gene 6700 out of 13692" [1] "fitting gene 6800 out of 13692" [1] "fitting gene 6900 out of 13692" [1] "fitting gene 7000 out of 13692" [1] "fitting gene 7100 out of 13692" [1] "fitting gene 7200 out of 13692" [1] "fitting gene 7300 out of 13692" [1] "fitting gene 7400 out of 13692" [1] "fitting gene 7500 out of 13692" [1] "fitting gene 7600 out of 13692" [1] "fitting gene 7700 out of 13692" [1] "fitting gene 7800 out of 13692" [1] "fitting gene 7900 out of 13692" [1] "fitting gene 8000 out of 13692" [1] "fitting gene 8100 out of 13692" [1] "fitting gene 8200 out of 13692" [1] "fitting gene 8300 out of 13692" [1] "fitting gene 8400 out of 13692" [1] "fitting gene 8500 out of 13692" [1] "fitting gene 8600 out of 13692" [1] "fitting gene 8700 out of 13692" [1] "fitting gene 8800 out of 13692" [1] "fitting gene 8900 out of 13692" [1] "fitting gene 9000 out of 13692" [1] "fitting gene 9100 out of 13692" [1] "fitting gene 9200 out of 13692" [1] "fitting gene 9300 out of 13692" [1] "fitting gene 9400 out of 13692" [1] "fitting gene 9500 out of 13692" [1] "fitting gene 9600 out of 13692" [1] "fitting gene 9700 out of 13692" [1] "fitting gene 9800 out of 13692" [1] "fitting gene 9900 out of 13692" [1] "fitting gene 10000 out of 13692" [1] "fitting gene 10100 out of 13692" [1] "fitting gene 10200 out of 13692" [1] "fitting gene 10300 out of 13692" [1] "fitting gene 10400 out of 13692" [1] "fitting gene 10500 out of 13692" [1] "fitting gene 10600 out of 13692" [1] "fitting gene 10700 out of 13692" [1] "fitting gene 10800 out of 13692" [1] "fitting gene 10900 out of 13692" [1] "fitting gene 11000 out of 13692" [1] "fitting gene 11100 out of 13692" [1] "fitting gene 11200 out of 13692" [1] "fitting gene 11300 out of 13692" [1] "fitting gene 11400 out of 13692" [1] "fitting gene 11500 out of 13692" [1] "fitting gene 11600 out of 13692" [1] "fitting gene 11700 out of 13692" [1] "fitting gene 11800 out of 13692" [1] "fitting gene 11900 out of 13692" [1] "fitting gene 12000 out of 13692" [1] "fitting gene 12100 out of 13692" [1] "fitting gene 12200 out of 13692" [1] "fitting gene 12300 out of 13692" [1] "fitting gene 12400 out of 13692" [1] "fitting gene 12500 out of 13692" [1] "fitting gene 12600 out of 13692" [1] "fitting gene 12700 out of 13692" [1] "fitting gene 12800 out of 13692" [1] "fitting gene 12900 out of 13692" [1] "fitting gene 13000 out of 13692" [1] "fitting gene 13100 out of 13692" [1] "fitting gene 13200 out of 13692" [1] "fitting gene 13300 out of 13692" [1] "fitting gene 13400 out of 13692" [1] "fitting gene 13500 out of 13692" [1] "fitting gene 13600 out of 13692" 错误于match.arg(method): 'arg' should be one of “holm”, “hochberg”, “hommel”, “bonferroni”, “BH”, “BY”, “fdr”, “none”

2025年09月06日

library(tidyverse) library(maSigPro) ## 1 读入矫正矩阵 ------------------------------------------------------------- mat <- read_csv("geneMatrix_Control_normalized_log2cpm.csv") %>% column_to_rownames("symble") %>% as.matrix() ## 2 读 meta 并严格对齐 ------------------------------------------------------- meta <- read_csv("meta_Control.csv") ## 关键:让矩阵列顺序 与 设计矩阵行顺序 完全一致 meta <- meta %>% arrange(sample) # 先排序 mat <- mat[, meta$sample] # 再按同样顺序重排矩阵列 ## 3 构建设计矩阵(行名 = 样本名) ------------------------------------------- design <- data.frame(time = meta$time, replicate = factor(meta$replicate)) rownames(design) <- meta$sample ## 4 跑 maSigPro(Gaussian,不加 counts) fit <- p.vector(mat, design, Q = 0.05, family = "gaussian") tfit <- T.fit(fit, step.method = "two.ways.backward", alfa = 0.05) sig <- get.siggenes(tfit, rsq = 0.6) ## 5 写出结果 prefix <- "maSigPro_results/Control" dir.create(dirname(prefix), showWarnings = FALSE) write_csv(sig$sig.genes %>% as_tibble(rownames = "gene"), str_c(prefix, "_sig_genes.csv")) write_csv(tfit$sig.models %>% as_tibble(rownames = "gene"), str_c(prefix, "_coef.csv")) pdf(str_c(prefix, "_trends.pdf"), width = 8, height = 5) plot(tfit, name = "Control", clustering = TRUE) dev.off()

2025年09月06日

> ## 1 读入并强制按同一顺序排列 ------------------------------------------ > counts <- read_csv("geneMatrix_Control_normalized_log2cpm.csv") %>% + column_to_rownames("symble") %>% + as.matrix() Rows: 13692 Columns: 13 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (1): symble dbl (12): 24hC1, 5DC1, 6hC1, 72hC1, 24hC2, 5DC2, 6hC2, 72hC2, 24hC3, 5DC3, 6hC3, 72hC3 ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. > > meta0 <- read_csv("meta_Control.csv") # 原始 meta Rows: 12 Columns: 4 ── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (2): sample, group dbl (2): time, replicate ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. > > ## 关键:让矩阵列顺序 与 设计矩阵行顺序 完全一致 > meta <- meta0 %>% arrange(sample) # 先排序 > counts <- counts[, meta$sample] # 再按同样顺序重排矩阵列 > > ## 2 构建设计矩阵 -------------------------------------------------------- > design <- data.frame(time = meta$time, + replicate = factor(meta$replicate)) > > ## 3 跑 maSigPro(标准化数据,Gaussian) > fit <- p.vector(counts, design, Q = 0.05, family = "gaussian") 错误于dat[, as.character(rownames(dis))]: 下标出界

2025年09月06日