| df2protdata | R Documentation |
Converts data frame df to a a protdata object, which can be used for further analysis.
df2protdata(df, acc_col, quant_cols, quant_name = "quant_value", run_name = NULL, annotations = NULL)
df |
A data frame that needs to be converted to a |
acc_col |
A character string or numeric index indicating the column in data frame |
quant_cols |
A vector of character strings or numeric indices indicating which column(s) in the data frame |
quant_name |
A character string indicating the name that will be given to the column that will contain the quantitative values of interest (mostly peptide intensities or peptide areas under the curve). Defaults to |
run_name |
If quant_cols contains more than one element (i.e. the data is in "wide" format), this should contain a freely chosen character string indicating the name that will be given to the column containing the mass spec run names. If no name is chosen ( |
annotations |
A vector of character strings or numeric indices indicating the columns in the data frame |
A protdata object.
#This example will convert df object peptides into a protdata object proteins.
#Import the data as a df object
pepdf <- read.table(system.file("extdata/CPTAC", "peptides.txt", package = "MSqRob"), sep="\t", header=TRUE)
#To save time, we only take the first 50 peptides as an example
pepdf <- pepdf[1:50,]
#Determine columns that contain the intensity values
quant_cols <- colnames(pepdf)[which(grepl("Intensity.",colnames(pepdf)))]
#Log2 transform data and change -Inf to NA
pepdf[,quant_cols] <- log2(pepdf[,quant_cols])
tmp_ints <- pepdf[,quant_cols]
tmp_ints <- as.matrix(tmp_ints)
tmp_ints[is.infinite(tmp_ints)] <- NA
tmp_ints <- as.data.frame(tmp_ints)
pepdf[,quant_cols] <- tmp_ints
#Keep only columns of interest
pepdf <- pepdf[,c(quant_cols,"Proteins","Sequence","PEP")]
#Dermine the column that contains the protein names
acc_col <- "Proteins"
proteins <- df2protdata(pepdf, acc_col, quant_cols)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.