@@ -1254,7 +1254,8 @@ res_lrt <- results(dds_lrt)
1254
1254
1255
1255
``` R
1256
1256
# ## Initialize output table with normalized counts ###
1257
- output_table <- tibble :: rownames_to_column(normCounts , var = gene_id )
1257
+ gene_id_type <- " ENSEMBL"
1258
+ output_table <- tibble :: rownames_to_column(normCounts , var = gene_id_type )
1258
1259
1259
1260
# ## Iterate through Wald Tests to generate pairwise comparisons of all groups ###
1260
1261
compute_contrast <- function (i ) {
@@ -1314,43 +1315,34 @@ annot <- read.table(annotations_link,
1314
1315
sep = " \t " ,
1315
1316
header = TRUE ,
1316
1317
quote = " " ,
1317
- comment.char = " " ,
1318
- row.names = 1
1318
+ comment.char = " "
1319
1319
)
1320
1320
1321
1321
# ## Combine annotations table and the DGE table ###
1322
- output_table <- merge(annot , output_table , by = ' row.names' , all.y = TRUE )
1323
- output_table <- annot %> %
1324
- merge(output_table ,
1325
- by = gene_id ,
1326
- all.y = TRUE
1327
- ) %> %
1328
- select(all_of(gene_id ), everything())
1329
-
1330
- if (! (gene_id %in% colnames(annot )) || ! (gene_id %in% colnames(output_table ))) {
1331
- # If gene ID column is missing from either table, just write the original DGE table
1332
- output_table2 <- output_table
1333
- warning(paste(" Gene ID column" , gene_id , " not found in one or both tables." ))
1322
+ # If gene ID column is missing from either table, just write the original DGE table
1323
+ if (! (gene_id_type %in% colnames(annot )) || ! (gene_id_type %in% colnames(output_table ))) {
1324
+ warning(paste(" Gene ID column" , gene_id_type , " not found in both tables." ))
1334
1325
} else {
1335
1326
# ## Combine annotations with data
1336
1327
output_table <- annot %> %
1337
1328
merge(output_table ,
1338
- by = gene_id ,
1329
+ by = gene_id_type ,
1339
1330
all.y = TRUE
1340
1331
) %> %
1341
- select(all_of(gene_id ), everything()) # Make sure main gene ID is first column
1332
+ select(all_of(gene_id_type ), everything()) # Make sure main gene ID is first column
1342
1333
}
1343
1334
1344
1335
```
1345
1336
1346
1337
** Input Data:**
1347
1338
1339
+ - ` gene_id_type ` (Gene identifier type, e.g. ENSEMBL, used to merge the annotations with the DGE results)
1348
1340
- ` normCounts ` (data frame of normalized counts, output from [ Step 8e] ( #8e-perform-dge-analysis ) )
1349
1341
- ` res_lrt ` (results object from likelihood ratio test, output from [ Step 8e] ( #8e-perform-dge-analysis ) )
1350
1342
- ` contrasts ` (matrix defining pairwise comparisons, output from [ Step 8c] ( #8c-configure-metadata-sample-grouping-and-group-comparisons ) )
1351
1343
- ` dds ` (DESeq2 data object containing normalized counts, experimental design, and differential expression results, output from [ Step 8e] ( #8e-perform-dge-analysis ) )
1352
1344
- ` annotations_link ` (variable containing URL to GeneLab gene annotation table, output from [ Step 8b] ( #8b-environment-set-up ) )
1353
- - ` gene_id ` (Gene id type, e.g. ENSEMBL, used to merge the annotations with the DGE results)
1345
+
1354
1346
** Output Data:**
1355
1347
1356
1348
- ` output_table ` (data frame containing the following columns:
0 commit comments