Skip to content

Commit c06ba5b

Browse files
committed
fix dge table gene annotation cols ordering
1 parent 1867a12 commit c06ba5b

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

RNAseq/Pipeline_GL-DPPD-7101_Versions/GL-DPPD-7101-G.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,10 +1521,12 @@ annot <- read.table(annotations_link,
15211521

15221522
### Combine annotations table and the DGE table ###
15231523
output_table <- merge(annot, output_table, by='row.names', all.y=TRUE)
1524-
output_table <- output_table %>%
1525-
rename(
1526-
ENSEMBL = Row.names ## Change ENSEMBL to TAIR for plant studies ##
1527-
)
1524+
output_table <- annot %>%
1525+
merge(output_table,
1526+
by = params$gene_id_type,
1527+
all.y = TRUE
1528+
) %>%
1529+
select(all_of(params$gene_id_type), everything())
15281530

15291531
```
15301532

@@ -1540,6 +1542,7 @@ output_table <- output_table %>%
15401542

15411543
* `output_table` (data frame containing the following columns:
15421544
- Gene identifier column (ENSEMBL or TAIR for plant studies)
1545+
- Additional organism-specific gene annotations columns
15431546
- Normalized counts for each sample
15441547
- For each pairwise comparison:
15451548
- Log2 fold change
@@ -1552,7 +1555,6 @@ output_table <- output_table %>%
15521555
- For each experimental group:
15531556
- Group.Mean_(group) (mean within group)
15541557
- Group.Stdev_(group) (standard deviation within group))
1555-
- Additional organism-specific gene annotations columns
15561558

15571559
<br>
15581560

RNAseq/Workflow_Documentation/NF_RCP/workflow_code/bin/add_gene_annotations.Rmd

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,20 @@ df <- read.csv(params$input_table_path,
5151
```
5252

5353
```{r, add-annotations}
54-
### Combine annotations table and the (non-ERCC) normalized counts table
55-
df2 <- merge(
56-
annot,
57-
df,
58-
by = params$gene_id_type,
59-
# ensure all original dge rows are kept.
60-
# If unmatched in the annotation database, then fill missing with NAN
61-
all.y = TRUE
62-
)
54+
### Check if gene ID column exists in both tables
55+
if (!(params$gene_id_type %in% colnames(annot)) || !(params$gene_id_type %in% colnames(df))) {
56+
# If gene ID column is missing from either table, just write the original DGE table
57+
df2 <- df
58+
warning(paste("Gene ID column", params$gene_id_type, "not found in one or both tables."))
59+
} else {
60+
### Combine annotations with data
61+
df2 <- annot %>%
62+
merge(df,
63+
by = params$gene_id_type,
64+
all.y = TRUE
65+
) %>%
66+
select(all_of(params$gene_id_type), everything()) # Make sure main gene ID is first column
67+
}
6368
6469
dir.create(dirname(paste0(params$output_directory)), recursive = TRUE)
6570
write.csv(

0 commit comments

Comments
 (0)