Skip to content

Commit

Permalink
few minor changes to make it compatible with CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Nazarov committed Jul 27, 2015
1 parent bcb14a5 commit ca0bf34
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 22 deletions.
3 changes: 3 additions & 0 deletions R/datatools.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
########## Support functions for managing the data ##########


#' Fix alleles - remove allele informatio from columns with genes.
#'
#' @param .data Either tcR data frame or a list with tcR data frames.
fix.alleles <- function (.data) {
if (has.class(.data, "list")) {
lapply(.data, fix.alleles)
Expand Down
16 changes: 8 additions & 8 deletions R/docdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ AA_TABLE_REVERSED <- AA_TABLE_REVERSED[order(names(AA_TABLE_REVERSED))]
#'
#' @name segments.alphabets
#'
#' @aliases genealphabets HUMAN_TRAV HUMAN_TRAJ HUMAN_TRBV HUMAN_TRBD HUMAN_TRBJ HUMAN_TRBV_MITCR HUMAN_TRGV HUMAN_TRGJ HUMAN_TRDV HUMAN_TRDD HUMAN_TRDJ
#' @aliases genealphabets HUMAN_TRAV HUMAN_TRAJ HUMAN_TRBV HUMAN_TRBD HUMAN_TRBJ HUMAN_TRBV_MITCR HUMAN_TRGV HUMAN_TRGJ HUMAN_TRDV HUMAN_TRDD HUMAN_TRDJ MOUSE_TRBV MOUSE_TRBJ
#'
#' @usage
#' HUMAN_TRAV
Expand Down Expand Up @@ -126,13 +126,13 @@ HUMAN_TRBV_MITCR <- c('TRBV10-1', 'TRBV10-2', 'TRBV10-3', 'TRBV11-1', 'TRBV11-2'
'TRBV5-6', 'TRBV5-8', 'TRBV6-1', 'TRBV6-3, TRBV6-2', 'TRBV6-4', 'TRBV6-5', 'TRBV6-6', 'TRBV6-7',
'TRBV7-1', 'TRBV7-2', 'TRBV7-3', 'TRBV7-4', 'TRBV7-6', 'TRBV7-7', 'TRBV7-8', 'TRBV7-9', 'TRBV9')

HUMAN_TRBV_ALS <- c('TRBV10-1', 'TRBV10-2', 'TRBV10-3', 'TRBV11-1', 'TRBV11-2', 'TRBV11-3', 'TRBV12-4', 'TRBV12-3',
'TRBV12-5', 'TRBV13', 'TRBV14', 'TRBV15', 'TRBV16', 'TRBV18', 'TRBV19', 'TRBV2*01',
'TRBV20-1', 'TRBV21-1', 'TRBV23-1', 'TRBV24-1', 'TRBV25-1', 'TRBV27', 'TRBV28', 'TRBV29-1',
'TRBV3-1*01', 'TRBV30', 'TRBV4-1', 'TRBV4-2', 'TRBV4-3', 'TRBV5-1', 'TRBV5-4', 'TRBV5-5',
'TRBV5-6', 'TRBV5-8', 'TRBV6-1', 'TRBV6-3', 'TRBV6-2', 'TRBV6-4', 'TRBV6-5', 'TRBV6-6',
'TRBV6-7', 'TRBV7-1', 'TRBV7-2', 'TRBV7-3', 'TRBV7-4', 'TRBV7-6', 'TRBV7-7', 'TRBV7-8',
'TRBV7-9', 'TRBV9')
# HUMAN_TRBV_ALS <- c('TRBV10-1', 'TRBV10-2', 'TRBV10-3', 'TRBV11-1', 'TRBV11-2', 'TRBV11-3', 'TRBV12-4', 'TRBV12-3',
# 'TRBV12-5', 'TRBV13', 'TRBV14', 'TRBV15', 'TRBV16', 'TRBV18', 'TRBV19', 'TRBV2*01',
# 'TRBV20-1', 'TRBV21-1', 'TRBV23-1', 'TRBV24-1', 'TRBV25-1', 'TRBV27', 'TRBV28', 'TRBV29-1',
# 'TRBV3-1*01', 'TRBV30', 'TRBV4-1', 'TRBV4-2', 'TRBV4-3', 'TRBV5-1', 'TRBV5-4', 'TRBV5-5',
# 'TRBV5-6', 'TRBV5-8', 'TRBV6-1', 'TRBV6-3', 'TRBV6-2', 'TRBV6-4', 'TRBV6-5', 'TRBV6-6',
# 'TRBV6-7', 'TRBV7-1', 'TRBV7-2', 'TRBV7-3', 'TRBV7-4', 'TRBV7-6', 'TRBV7-7', 'TRBV7-8',
# 'TRBV7-9', 'TRBV9')


HUMAN_TRGV <- c()
Expand Down
16 changes: 9 additions & 7 deletions R/input.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ parse.cloneset <- function (.filename,

#' Parse input table files with immune receptor repertoire data.
#'
#' @aliases parse.folder parse.file.list parse.file parse.mitcr parse.mitcrbc parse.migec parse.vdjtools parse.immunoseq
#' @aliases parse.folder parse.file.list parse.file parse.mitcr parse.mitcrbc parse.migec parse.vdjtools parse.immunoseq parse.imseq parse.mixcr
#'
#' @description
#' Load the TCR data from the file with the given filename to a data frame or load all
Expand All @@ -210,13 +210,13 @@ parse.cloneset <- function (.filename,
#'
#' @usage
#' parse.file(.filename,
#' .format = c('mitcr', 'mitcrbc', 'migec', 'vdjtools', 'immunoseq', 'mixcr', 'imseq'), ...)
#' .format = c('mitcr', 'mitcrbc', 'migec'), ...)
#'
#' parse.file.list(.filenames,
#' .format = c('mitcr', 'mitcrbc', 'migec', 'vdjtools', 'immunoseq', 'mixcr', 'imseq'), .namelist = NA)
#' .format = c('mitcr', 'mitcrbc', 'migec'), .namelist = NA)
#'
#' parse.folder(.folderpath,
#' .format = c('mitcr', 'mitcrbc', 'migec', 'vdjtools', 'immunoseq', 'mixcr', 'imseq'), ...)
#' .format = c('mitcr', 'mitcrbc', 'migec'), ...)
#'
#' parse.mitcr(.filename)
#'
Expand Down Expand Up @@ -288,11 +288,12 @@ parse.cloneset <- function (.filename,
#' # Parse all files in "~/data/" as MiGEC files.
#' immdata <- parse.folder("~/data/", 'migec')
#' }
parse.folder <- function (.folderpath, .format = c('mitcr', 'mitcrbc', 'migec', 'vdjtools', 'immunoseq', 'mixcr', 'imseq'), ...) {
parse.folder <- function (.folderpath, .format = c('mitcr', 'mitcrbc', 'migec'), ...) {
parse.file.list(list.files(.folderpath, full.names = T), .format)
}

parse.file.list <- function (.filenames, .format = c('mitcr', 'mitcrbc', 'migec', 'vdjtools', 'immunoseq', 'mixcr', 'imseq'), .namelist = NA) {
parse.file.list <- function (.filenames, .format = c('mitcr', 'mitcrbc', 'migec'),
.namelist = NA) {
# Remove full paths and extension from the given string.
.remove.ext <- function (.str) {
gsub(pattern = '.*/|[.].*$', replacement = '', x = .str)
Expand All @@ -316,7 +317,7 @@ parse.file.list <- function (.filenames, .format = c('mitcr', 'mitcrbc', 'migec'
datalist
}

parse.file <- function(.filename, .format = c('mitcr', 'mitcrbc', 'migec', 'vdjtools', 'immunoseq', 'mixcr', 'imseq'), ...) {
parse.file <- function(.filename, .format = c('mitcr', 'mitcrbc', 'migec'), ...) {
parse.fun <- switch(.format[1],
mitcr = parse.mitcr,
mitcrbc = parse.mitcrbc,
Expand Down Expand Up @@ -699,6 +700,7 @@ parse.mixcr <- function (.filename) {
}

parse.imseq <- function (.filename) {
cat("WARNING: I can't understand which chain is it, so you need to modify gene columns in order to use this data frame with tcR.\n")
f <- gzfile(.filename)
all.lines <- strsplit(readLines(f), ":", T, useBytes = T)
close(f)
Expand Down
4 changes: 2 additions & 2 deletions R/segments.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ geneUsage <- function (.data, .genes = HUMAN_TRBV_MITCR, .quant = c(NA, "read.co
#' Perform PCA on gene segments frequency data for V- and J-segments and either return pca object or plot the results.
#'
#' @usage
#' pca.segments(.data, .cast.freq.seg = T, ..., .do.plot = T)
#' pca.segments(.data, .cast.freq.seg = T, ..., .text = T, .do.plot = T)
#'
#' pca.segments.2D(.data, .cast.freq.seg = T, ..., .do.plot = T)
#' pca.segments.2D(.data, .cast.freq.seg = T, ..., .text = T, .do.plot = T)
#'
#' @param .data Either data.frame or a list of data.frame or a result obtained from the \code{geneUsage} function.
#' @param .cast.freq.seg if T then apply code{geneUsage} to the supplied data.
Expand Down
Binary file modified data/twa.rda
Binary file not shown.
15 changes: 15 additions & 0 deletions man/fix.alleles.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/datatools.R
\name{fix.alleles}
\alias{fix.alleles}
\title{Fix alleles - remove allele informatio from columns with genes.}
\usage{
fix.alleles(.data)
}
\arguments{
\item{.data}{Either tcR data frame or a list with tcR data frames.}
}
\description{
Fix alleles - remove allele informatio from columns with genes.
}

8 changes: 5 additions & 3 deletions man/parse.folder.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
\alias{parse.file.list}
\alias{parse.folder}
\alias{parse.immunoseq}
\alias{parse.imseq}
\alias{parse.migec}
\alias{parse.mitcr}
\alias{parse.mitcrbc}
\alias{parse.mixcr}
\alias{parse.vdjtools}
\title{Parse input table files with immune receptor repertoire data.}
\usage{
parse.file(.filename,
.format = c('mitcr', 'mitcrbc', 'migec', 'vdjtools', 'immunoseq', 'mixcr', 'imseq'), ...)
.format = c('mitcr', 'mitcrbc', 'migec'), ...)

parse.file.list(.filenames,
.format = c('mitcr', 'mitcrbc', 'migec', 'vdjtools', 'immunoseq', 'mixcr', 'imseq'), .namelist = NA)
.format = c('mitcr', 'mitcrbc', 'migec'), .namelist = NA)

parse.folder(.folderpath,
.format = c('mitcr', 'mitcrbc', 'migec', 'vdjtools', 'immunoseq', 'mixcr', 'imseq'), ...)
.format = c('mitcr', 'mitcrbc', 'migec'), ...)

parse.mitcr(.filename)

Expand Down
4 changes: 2 additions & 2 deletions man/pca.segments.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
\alias{pca.segments.2D}
\title{Perform PCA on segments frequency data.}
\usage{
pca.segments(.data, .cast.freq.seg = T, ..., .do.plot = T)
pca.segments(.data, .cast.freq.seg = T, ..., .text = T, .do.plot = T)

pca.segments.2D(.data, .cast.freq.seg = T, ..., .do.plot = T)
pca.segments.2D(.data, .cast.freq.seg = T, ..., .text = T, .do.plot = T)
}
\arguments{
\item{.data}{Either data.frame or a list of data.frame or a result obtained from the \code{geneUsage} function.}
Expand Down
2 changes: 2 additions & 0 deletions man/segments.alphabets.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
\alias{HUMAN_TRDV}
\alias{HUMAN_TRGJ}
\alias{HUMAN_TRGV}
\alias{MOUSE_TRBJ}
\alias{MOUSE_TRBV}
\alias{genealphabets}
\alias{segments.alphabets}
\title{Alphabets of TCR and Ig gene segments.}
Expand Down

0 comments on commit ca0bf34

Please sign in to comment.