knitr::opts_chunk$set( echo = TRUE, message = FALSE, warning = FALSE, eval = FALSE )
Thank you for your interest in contributing to mLLMCelltype! This guide will help you understand how to contribute to the project effectively.
git clone https://github.com/YOUR-USERNAME/mLLMCelltype.git
cd mLLMCelltype
git remote add upstream https://github.com/cafferychen777/mLLMCelltype.git
For R package development:
# Install required packages for development install.packages(c("devtools", "roxygen2", "testthat", "knitr", "rmarkdown")) # Install the package in development mode devtools::install_dev("R")
The mLLMCelltype project has the following structure:
mLLMCelltype/ ├── R/ # R package source code │ ├── R/ # R functions │ ├── man/ # Documentation │ ├── tests/ # Unit tests │ ├── vignettes/ # Package vignettes │ └── DESCRIPTION # Package metadata ├── python/ # Python package source code ├── .github/ # GitHub workflows and templates ├── assets/ # Images and other assets ├── examples/ # Example notebooks and scripts └── README.md # Project overview
git checkout -b feature/your-feature-name
git add .
git commit -m "Add your descriptive commit message here"
git push origin feature/your-feature-name
We follow the tidyverse style guide for R code:
Example of properly formatted R code:
#' Annotate Cell Types #' #' This function annotates cell types based on marker genes. #' #' @param input A data frame containing marker genes. #' @param tissue_name The name of the tissue. #' @param model The LLM model to use. #' @param api_key The API key for the LLM provider. #' #' @return A vector of cell type annotations. #' @export annotate_cell_types <- function(input, tissue_name, model, api_key) { # Function implementation results <- process_markers(input, top_n = 10) for (i in seq_along(results)) { if (is_valid_result(results[i])) { results[i] <- clean_result(results[i]) } } return(results) }
All functions should be documented using roxygen2 with the following sections:
We use the testthat package for testing. Tests should be placed in the R/tests/testthat/ directory.
To run tests:
devtools::test()
Example test file (test-annotate_cell_types.R):
context("Cell type annotation") test_that("annotate_cell_types returns expected format", { # Setup test data test_markers <- data.frame( cluster = c(0, 0, 1, 1), gene = c("CD3D", "CD3E", "CD19", "MS4A1"), avg_log2FC = c(2.5, 2.3, 3.1, 2.8), p_val_adj = c(0.001, 0.002, 0.001, 0.003) ) # Mock the API response mockery::stub( annotate_cell_types, "get_model_response", function(...) c("T cells", "B cells") ) # Run the function result <- annotate_cell_types( input = test_markers, tissue_name = "test tissue", model = "test-model", api_key = "test-key" ) # Assertions expect_is(result, "character") expect_length(result, 2) expect_equal(result, c("T cells", "B cells")) })
To add support for a new LLM model:
R/R/process_[provider].Rget_provider() function in R/R/get_provider.RExample of adding a new model:
# In process_newprovider.R process_newprovider <- function(prompt, api_key) { # Implementation for the new provider url <- "https://api.newprovider.com/v1/completions" headers <- c( "Content-Type" = "application/json", "Authorization" = paste("Bearer", api_key) ) body <- list( model = "newprovider-model", prompt = prompt, max_tokens = 1000, temperature = 0.1 ) # Make API request using httr response <- httr::POST( url = url, httr::add_headers(.headers = headers), body = jsonlite::toJSON(body, auto_unbox = TRUE), encode = "json" ) # Check for HTTP errors httr::stop_for_status(response) # Parse the response content <- httr::content(response, "text", encoding = "UTF-8") parsed_response <- jsonlite::fromJSON(content) result <- parsed_response$choices[[1]]$text return(result) } # In get_provider.R get_provider <- function(model) { # Add to the model mapping model_mapping <- list( # Existing models... "newprovider-model" = "newprovider" ) provider <- model_mapping[[model]] if (is.null(provider)) { stop("Unsupported model: ", model) } return(provider) }
Documentation improvements are always welcome:
Some ideas for new features:
When reporting issues, please include:
sessionInfo())All pull requests will be reviewed by the maintainers. The review process includes:
mLLMCelltype follows semantic versioning (MAJOR.MINOR.PATCH):
We follow a code of conduct to ensure a welcoming and inclusive community:
Contributors will be acknowledged in the package documentation and README.
By contributing to mLLMCelltype, you agree that your contributions will be licensed under the same license as the project (MIT License).
Now that you know how to contribute to mLLMCelltype, you can:
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.