---
title: '`r sprintf("Package Report: %s", params$package)`'
date: "`r Sys.Date()`"
output: 
  BiocStyle::html_document:
    toc: false
params:
  # change this to YOUR package name
  package: "GEOquery"
---

```{r include=FALSE}
library(knitr)
library(BiocStyle)
opts_chunk$set(message = FALSE, warning = FALSE, cache = TRUE)
```

```{r include=FALSE}
library(BiocPkgTools)
dls <- biocDownloadStats()
pkl <- biocPkgList()
pkl_me <- pkl[pkl$Package==params$package,]
```

# Downloads and Usage

```{r echo=FALSE}
#| fig.cap = paste0(
#|  "Package download counts. Bioconductor tracks the number of unique IP",
#|  " addresses that download individual packages. These numbers can be used",
#|  " as a proxy for the number of users of a software package.",
#| )
library(ggplot2)
library(dplyr)
downloads <- dls |>
    filter(Package == params$package) |>
    filter(!is.na(Date))
ggplot(downloads, aes(y=Nb_of_distinct_IPs, x=Date)) +
    geom_bar(stat='identity') +
    ylab("Distinct IP Downloads") +
    ggtitle("Number of Downloads")
```

# Dependencies

The `r params$package` package depends on `r length(pkl_me$Depends[1][[1]])`
packages and suggests `r length(pkl_me$Suggests[1][[1]])` packages.

```{r, echo=FALSE}
library(pkgndep)
pkg_report <-  pkgndep(params$package)
pkg_report
```

```{r,echo=FALSE}
rmd_dir <- dirname(knitr::current_input(dir = TRUE))
## NOTE. this command saves a file in the directory of the Rmd file
heatmap_file <- file.path(rmd_dir, "heatmap.png")
dependency_heatmap(pkg_report, file = heatmap_file)
```

```{r, echo=FALSE, results="asis"}
cat(paste0(
'<div style="overflow-x: auto; width: 100%; border: 1px solid #ddd;">\n',
'<img src="', heatmap_file,
'" alt="Dependency Heatmap" style="display: block; max-width: none;">\n',
'</div>'
))
```
