Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup the vignette #34

Merged
merged 12 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.99.2
current_version = 1.99.8
commit = True
commit_args = --no-verify
tag = True
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/rworkflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,20 @@ jobs:
bioc: release
r: auto
steps:
- run: apt-get update && apt-get install -y rsync qpdf
if: runner.os == 'Linux'
- uses: neurogenomics/rworkflows@master
with:
run_bioccheck: ${{ true }}
run_rcmdcheck: ${{ true }}
run_bioccheck: ${{ false }}
run_rcmdcheck: ${{ false }}
as_cran: ${{ true }}
run_vignettes: ${{ true }}
has_testthat: ${{ true }}
run_covr: ${{ true }}
run_pkgdown: ${{ true }}
run_vignettes: ${{ false }}
has_testthat: ${{ false }}
run_covr: ${{ false }}
run_pkgdown: ${{ false }}
has_runit: ${{ false }}
has_latex: ${{ false }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run_docker: ${{ false }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
runner_os: ${{ runner.os }}
cache_version: cache-v1
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: KRSA
Title: KRSA: Kinome Random Sampling Analyzer
Version: 1.99.2
Version: 1.99.8
Authors@R:
c(person(c("Ali", "Sajid"), "Imami", , "Ali.Sajid.Imami@gmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-3684-3539")),
Expand Down Expand Up @@ -53,3 +53,4 @@ Config/testthat/edition: 3
Config/testthat/parallel: TRUE
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
LazyData: false
33 changes: 22 additions & 11 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' KRSA kinase-substrate mapping file for PamChip 86402 PTK (v1 mapping)
#'
#' A data frame of the built-in KRSA kinase-substrate mapping file for PamChip 86402 PTK (v1 mapping)
#' A data frame of the built-in KRSA kinase-substrate mapping file
#' for PamChip 86402 PTK (v1 mapping)
#'
#' @format A data frame with 192 rows and 2 variables:
#' \describe{
Expand All @@ -13,7 +14,8 @@

#' KRSA kinase-substrate mapping file for PamChip 87102 STK (v1 mapping)
#'
#' A data frame of the built-in KRSA kinase-substrate mapping file for PamChip 87102 STK (v1 mapping)
#' A data frame of the built-in KRSA kinase-substrate mapping file
#' for PamChip 87102 STK (v1 mapping)
#'
#' @format A data frame with 141 rows and 2 variables:
#' \describe{
Expand All @@ -25,7 +27,8 @@

#' KRSA kinase coverage file for PamChip 86402 PTK (v1 mapping)
#'
#' A data frame of the built-in KRSA kinase coverage file for PamChip 86402 PTK (v1 mapping)
#' A data frame of the built-in KRSA kinase coverage file for PamChip
#' 86402 PTK (v1 mapping)
#'
#' @format A data frame with 1278 rows and 2 variables:
#' \describe{
Expand All @@ -37,7 +40,8 @@

#' KRSA kinase coverage file for PamChip 87102 STK (v1 mapping)
#'
#' A data frame of the built-in KRSA kinase coverage file for PamChip 87102 STK (v1 mapping)
#' A data frame of the built-in KRSA kinase coverage file for PamChip
#' 87102 STK (v1 mapping)
#'
#' @format A data frame with 2423 rows and 2 variables:
#' \describe{
Expand All @@ -47,9 +51,11 @@
#'
"KRSA_coverage_STK_PamChip_87102_v1"

#' KRSA kinase coverage file for PamChip 87102 STK (v2 mapping, removed PDK kinase)
#' KRSA kinase coverage file for PamChip 87102 STK (v2 mapping,
#' removed PDK kinase)
#'
#' A data frame of the built-in KRSA kinase coverage file for PamChip 87102 STK (v2 mapping)
#' A data frame of the built-in KRSA kinase coverage file for
#' PamChip 87102 STK (v2 mapping)
#'
#' @format A data frame with 2423 rows and 2 variables:
#' \describe{
Expand All @@ -62,20 +68,23 @@

#' Protein-Protein Interactions based on PhosphositePlus database
#'
#' A data frame of the known Protein-Protein Interactions based on PhosphositePlus database
#' A data frame of the known Protein-Protein Interactions based on
#' PhosphositePlus database
#'
#' @format A data frame with 179 rows and 2 variables:
#' \describe{
#' \item{FinName}{Kinase Family Name}
#' \item{count}{Number of collapsed kinases under that kinase family, it's not used in package}
#' \item{count}{Number of collapsed kinases under that kinase family,
#' it's not used in package}
#' }
#'
"ballModel_nodes"


#' Protein-Protein Interactions based on PhosphositePlus database
#'
#' A data frame of the known Protein-Protein Interactions based on PhosphositePlus database
#' A data frame of the known Protein-Protein Interactions based on
#' PhosphositePlus database
#'
#' @format A data frame with 592 rows and 2 variables:
#' \describe{
Expand All @@ -87,7 +96,8 @@

#' CDRL Complete mapping of peptides to HGNC symbols (STK PamChip 87102)
#'
#' A data frame of CDRL Complete mapping CDRL Complete mapping of peptides to HGNC symbols (STK PamChip 87102)
#' A data frame of CDRL Complete mapping CDRL Complete mapping of peptides
#' to HGNC symbols (STK PamChip 87102)
#'
#' @format A data frame with 141 rows and 2 variables:
#' \describe{
Expand All @@ -97,7 +107,8 @@

#' CDRL Complete mapping of peptides to HGNC symbols (PTK PamChip 86402)
#'
#' A data frame of CDRL Complete mapping CDRL Complete mapping of peptides to HGNC symbols (PTK PamChip 86402)
#' A data frame of CDRL Complete mapping CDRL Complete mapping of peptides to
#' HGNC symbols (PTK PamChip 86402)
#'
#' @format A data frame with 193 rows and 2 variables:
#' \describe{
Expand Down
48 changes: 26 additions & 22 deletions R/enrichr_lib_call.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#' Runs enrichr api (single GET call for a geneset library)
#'
#' This function takes in the geneset library name from Enrichr and userListId (id created by enrichr api) sand retruns tidy dataframe of all geneset terms in that library
#' This function takes in the geneset library name from Enrichr and
#' userListId (id created by enrichr api) sand retruns tidy dataframe of
#' all geneset terms in that library
#'
#' @param lib geneset library name from Enrichr
#' @param userListId id created by the POST enrichr api call
Expand All @@ -14,36 +16,38 @@
#'
#' @examples
#' TRUE


enrichr_lib_call <- function(lib, userListId) {

ENRICHR_URL = 'https://maayanlab.cloud/Enrichr/enrich'
query_string = '?userListId=%s&backgroundType=%s'
ENRICHR_URL <- "https://maayanlab.cloud/Enrichr/enrich"
query_string <- "?userListId=%s&backgroundType=%s"


full_link <- base::paste0(ENRICHR_URL,
"?userListId=",
userListId,
"&backgroundType=",
lib)
full_link <- base::paste0(
ENRICHR_URL,
"?userListId=",
userListId,
"&backgroundType=",
lib
)

base::message(base::paste0(lib, " ..."))
base::message(base::paste0(lib, " ..."))

res <- base::suppressMessages(jsonlite::fromJSON(httr::content(httr::GET(full_link), as="text")))

purrr::map(res[[1]], process_output) %>%
purrr::map_df(dplyr::bind_rows) %>%
dplyr::mutate(lib = lib)
res <- base::suppressMessages(jsonlite::fromJSON(httr::content(
httr::GET(full_link),
as = "text"
)))

purrr::map(res[[1]], process_output) %>%
purrr::map_df(dplyr::bind_rows) %>%
dplyr::mutate(lib = lib)
}

process_output <- function(x) {
x <- stats::setNames(x, c("index", "term", "pvalue", "odds_ratio", "combined_score",
"genes", "adjusted_pvalue", "old1", "old2"))

x[["genes"]] <- base::paste0(x[["genes"]], collapse = ", ")
x <- stats::setNames(x, c(
"index", "term", "pvalue", "odds_ratio", "combined_score",
"genes", "adjusted_pvalue", "old1", "old2"
))

x
x[["genes"]] <- base::paste0(x[["genes"]], collapse = ", ")

x
}
54 changes: 27 additions & 27 deletions R/krsa.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,32 @@
#'
#' @examples
#' TRUE


krsa <- function(peptides, itr = 2000, seed = 123, return_count = F, map_file = KRSA_file, cov_file = chipCov) {
message("Running KRSA ...")
set.seed(seed)

purrr::map_df(1:itr,krsa_sampling,cov_file ,map_file,length(peptides)) -> temp

temp %>%
dplyr::group_by(Kin) %>%
dplyr::summarise(SamplingAvg = mean(counts), SD= stats::sd(counts)) -> temp2

cov_file %>%
dplyr::group_by(Kin) %>%
dplyr::summarise(
Observed = sum(Substrates %in% peptides)
) -> temp3

dplyr::left_join(temp2, temp3) %>%
dplyr::mutate(Z = (Observed-SamplingAvg)/SD) %>%
dplyr::arrange(dplyr::desc(abs(Z))) %>%
dplyr::filter(!Kin %in% c("BARK1", "VRK2")) %>%
dplyr::select(Kin, Observed, SamplingAvg, SD, Z) %>%
dplyr::rename(Kinase = Kin) -> fin

if(return_count == T) {return(list(count_mtx = temp, KRSA_Table = fin))}
else {fin}

message("Running KRSA ...")
set.seed(seed)

purrr::map_df(1:itr, krsa_sampling, cov_file, map_file, length(peptides)) -> temp

temp %>%
dplyr::group_by(Kin) %>%
dplyr::summarise(SamplingAvg = mean(counts), SD = stats::sd(counts)) -> temp2

cov_file %>%
dplyr::group_by(Kin) %>%
dplyr::summarise(
Observed = sum(Substrates %in% peptides)
) -> temp3

dplyr::left_join(temp2, temp3) %>%
dplyr::mutate(Z = (Observed - SamplingAvg) / SD) %>%
dplyr::arrange(dplyr::desc(abs(Z))) %>%
dplyr::filter(!Kin %in% c("BARK1", "VRK2")) %>%
dplyr::select(Kin, Observed, SamplingAvg, SD, Z) %>%
dplyr::rename(Kinase = Kin) -> fin

if (return_count == T) {
return(list(count_mtx = temp, KRSA_Table = fin))
} else {
fin
}
}
Loading
Loading