Skip to content

Commit

Permalink
cazy are not unique
Browse files Browse the repository at this point in the history
  • Loading branch information
SilasK committed Oct 23, 2023
1 parent 25c7fe4 commit fd8e8f3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions R/Analyze_genecatalog.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,16 @@ write_delim(as.data.frame(gene_gcpm),


```{r}
rm(gene_coverage,gene_gcpm,gene_stats)
rm(gene_coverage, gene_gcpm, gene_stats)
gc()
```

## 2. Load only genes with annotations
Here we load KEGG annotations.
As alternative one can load the cazy annotation.

However, CAZy has multiple annotations per gene.
I need to write a function how to deal with this.

```{r }
Expand Down Expand Up @@ -446,9 +450,8 @@ colnames(annotated_genes_gcpm) <- colnames(data)
rm(data)
annotated_genes_gcpm[1:5, 1:5]
```

As genes can have multiple annotations we need to create a matrix with genes as columns and annotations as rows

In theory, genes can have multiple annotations we need to create a matrix with genes as columns and annotations as rows
KEGG annotations seem to be unique.

```{r}
Expand All @@ -460,17 +463,15 @@ annotation_matrix <- Matrix::sparseMatrix(
i = match(annotations$ko_id, ko_ids),
j = match(annotations$GeneName, gene_names_with_annotations),
x = 1,
dims = c(length(ko_ids),length(gene_names_with_annotations))
dims = c(length(ko_ids), length(gene_names_with_annotations))
)
colnames(annotation_matrix) <- gene_names_with_annotations
rownames(annotation_matrix) <- ko_ids
annotation_matrix[1:5,1:5]
annotation_matrix[1:5, 1:5]
cat(" Genes have max ", max(colSums(annotation_matrix)), " annotations.\n")
```


Expand All @@ -486,7 +487,7 @@ assertthat::assert_that(all(colnames(annotation_matrix) == rownames(annotated_ge
# multiply gene coverage with annotation matrix,
annotation_cpm <- annotation_matrix %*% annotated_genes_gcpm
annotation_cpm = as.matrix(annotation_cpm)
annotation_cpm <- as.matrix(annotation_cpm)
annotation_cpm[1:5, 1:5]
```
Expand Down

0 comments on commit fd8e8f3

Please sign in to comment.