R/assignOptionalFields.R

#' Function that creates blank columns that openSpecimen has to have....
#' 
#' @export
#' @param new.df The finished file, after running getLoc(), getRequiredFields(), and assignBar()
#' @param df The old manifest file
#'  
#' @return A bulk upload file template
#' 
#' @examples
#' new.df <- assignDummy(df, new.df)

getRequiredFields <- function(df, new.df){
  
  proj <- readline('What project is this from? (ex: SCD) ' )
  orig_vol <- readline('How much of the original stock volume was there in uL? (ex: 20) ')
  cur_vol <- readline('How much volume in uL is left? (ex: 20) ')
  prep_method <- readline('What was the sample prep method? (ex: Qiagen QIAamp DNA FFPE Tissue Kit) ')
  
  ask <- readline('What is the column of the manifest file for age called? ')
  index <- grep(paste0('\\b', ask, '\\b'), colnames(df))
  age <- as.data.frame(df[,grep(paste0('\\b', ask, '\\b'), colnames(df))])
  ask <- readline('What is the column of the manifest file for sex called? ')
  sex <- as.data.frame(df[,grep(paste0('\\b', ask, '\\b'), colnames(df))])
  ask <- readline('What is the column of the manifest file for race called? ')
  race <- as.data.frame(df[,grep(paste0('\\b', ask, '\\b'), colnames(df))])
  ask <- readline('What is the column of the manifest file for cause of death called? ')
  dth <- as.data.frame(df[,grep(paste0('\\b', ask, '\\b'), colnames(df))])
  
  new.df$`Arking Specimen Form#Isolation Method` <- prep_method
  new.df$`Arking Specimen Form#Cause of Death` <- dth
  new.df$`Arking Specimen Form#Original Stock Volume (uL)` <- orig_vol
  new.df$`Arking Specimen Form#Current Volume Remaining (uL)` <- cur_vol
  new.df$`Arking Specimen Form#Concentration in ng/uL` <- 'On Tubes'
  new.df$`Arking Specimen Form#Age (years)` <- age
  new.df$`Arking Specimen Form#Project` <- proj
  new.df$Gender <- sex
  new.df$Race <- race
}
syyang93/openSpec documentation built on May 16, 2019, 3:24 p.m.