getFile: getFile

Description Usage Arguments Value Author(s) Examples

View source: R/SCRNA.R

Description

Takes in a filename/path and checks if the file exists or is empty. Then it checks that it is either a .csv or a .txt file. If it is empty or does not exist it stops and reports this. If it is not a .csv or .txt it stops and reports this. If it is a .csv or .txt it will create a dataframe from the data and return it filtered for cell barcodes with colsums >= 500

Usage

1
getFile(filepath)

Arguments

filepath

The file name or path as a string

Value

returns a dataframe of the scppin form the file if it is in the proper format

Author(s)

Matt Heffernan, University of Illinois at Chicago

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

getFile("GSM4008666_Adult-Uterus1_dge.txt")

## The function is currently defined as
function (filepath) 
{
    if ((file.exists(filepath)) & (file.size(filepath) > 0)) {
        if (grepl(".csv", filepath, fixed = T)) {
            Data <- read.csv(filepath, header = T, row.names = 1)
        }
        else if (grepl(".txt", filepath, fixed = T)) {
            Data <- read.delim(filepath, header = T, row.names = 1)
        }
        else {
            stop("FILE NOT IN PROPER FORMAT (.csv OR .txt)")
        }
    }
    else {
        stop("FILE DOES NOT EXIST OR IS EMPTY")
    }
    Data <- Data[, colSums(Data) >= 500]
    return(Data)
  }

mheffe3/SCNVC documentation built on Dec. 21, 2021, 5:52 p.m.