On Thu, Jun 27, 2019 at 10:48 AM Spencer Brackett < spbracket...@saintjosephhs.com> wrote:
> Hello, > > Was that helpful in clarifying? > > Best, > > Spencer > > On Tue, Jun 25, 2019 at 5:14 PM Spencer Brackett < > spbracket...@saintjosephhs.com> wrote: > >> Thank you! The following is the result of the corrected code using >> >cnames .... >> >> > cnames >> [1] "sample.NA.NA.NANA" "TCGA.27.1832.01.NA.NA.NANA" >> "TCGA.27.1831.01.NA.NA.NANA" >> [4] "TCGA.28.5216.01.NA.NA.NANA" "TCGA.16.0846.01.NA.NA.NANA" >> "TCGA.28.5218.01.NA.NA.NANA" >> [7] "TCGA.06.0178.01.NA.NA.NANA" "TCGA.06.0238.01.NA.NA.NANA" >> "TCGA.06.0125.01.NA.NA.NANA" >> [10] "TCGA.06.0219.01.NA.NA.NANA" >> >> And then the first 2 lines of the output for the corrected paste() bit of >> the original coding... >> >> [[1]] >> [1] "sample.NA.NA.NA" >> >> [[2]] >> [1] "TCGA.27.1832.01.NA.NA.NANA" >> >> I would have to reconvene with my instructor who wrote the original code >> to determine what his desired output for the data would be, but from what I >> can tell, this bit of coding is formatting the given dataset(s) that we are >> working with, prepping them for what will be a Linear regression model of >> the protein expression datatype contained with the larger dataset. Sorry, I >> know that this explanation doesn't really narrow things down. >> >> For reference, here are the proceeding few lines of code following the >> paste() function portion; specifically after the "})" ... >> >> exp = read.table(file = >> "/rsrch1/bcb/kchen_group/v_mohanty/data/TCGA/RNAseq/GBM.txt", sep = "\t", >> header = T, row.names = 1) >> exp = as.matrix(exp) >> c = intersect(colnames(exp),colnames(meth)) >> exp = exp[,c] >> meth = meth[,c] >> m = apply(meth, 1, function(i){ >> log2(i/(1-i)) >> }) >> >> Best, >> >> Spencer Brackett >> >> On Tue, Jun 25, 2019 at 4:54 PM Rui Barradas <ruipbarra...@sapo.pt> >> wrote: >> >>> Hello, >>> >>> The following works. >>> First, get the colnames you have posted in a format that R can process. >>> in your code you would skip this. >>> >>> cnames <- scan(what = character(), text = ' >>> "sample.NA.NA.NANA" >>> "TCGA.27.1832.01.NA.NA.NANA" >>> "TCGA.27.1831.01.NA.NA.NANA" >>> "TCGA.28.5216.01.NA.NA.NANA" >>> "TCGA.16.0846.01.NA.NA.NANA" >>> "TCGA.28.5218.01.NA.NA.NANA" >>> "TCGA.06.0178.01.NA.NA.NANA" >>> "TCGA.06.0238.01.NA.NA.NANA" >>> "TCGA.06.0125.01.NA.NA.NANA" >>> "TCGA.06.0219.01.NA.NA.NANA" >>> ') >>> cnames >>> >>> >>> Now your code corrected. I do not understand the output you are >>> expecting. Can you give an example of the expected output of, say, the >>> first 2 or 3 strings? >>> >>> lapply(cnames, function(i){ >>> c1 <- strsplit(i, split = '\\.')[[1]] >>> c1[4] <- paste(strsplit(c1[4], split = "",fixed = T)[[1]][1:2], >>> collapse = "") >>> paste(c1, collapse = ".") >>> }) >>> >>> >>> Hope this helps, >>> >>> Rui Barradas >>> >>> Às 20:24 de 25/06/19, Spencer Brackett escreveu: >>> > Mr. Barradas, >>> > >>> > Oh haha my mistake. The following is the output you requested.... >>> > >>> > [1] "sample.NA.NA.NANA" >>> > [2] "TCGA.27.1832.01.NA.NA.NANA" >>> > [3] "TCGA.27.1831.01.NA.NA.NANA" >>> > [4] "TCGA.28.5216.01.NA.NA.NANA" >>> > [5] "TCGA.16.0846.01.NA.NA.NANA" >>> > [6] "TCGA.28.5218.01.NA.NA.NANA" >>> > [7] "TCGA.06.0178.01.NA.NA.NANA" >>> > [8] "TCGA.06.0238.01.NA.NA.NANA" >>> > [9] "TCGA.06.0125.01.NA.NA.NANA" >>> > [10] "TCGA.06.0219.01.NA.NA.NANA" >>> > >>> > Best, >>> > >>> > Spencer >>> > >>> > On Tue, Jun 25, 2019 at 2:50 PM Rui Barradas <ruipbarra...@sapo.pt >>> > <mailto:ruipbarra...@sapo.pt>> wrote: >>> > >>> > Hello, >>> > >>> > No, you have not understood, post the colnames, not the row.names. >>> > >>> > Run >>> > >>> > colnames(meth)[1:10] >>> > >>> > and post the output of that code line. >>> > >>> > Hope this helps, >>> > >>> > Rui Barradas >>> > >>> > Às 19:31 de 25/06/19, Spencer Brackett escreveu: >>> > > The requested reprex.... >>> > > >>> > > Rendering reprex... >>> > > Error in parse(text = x, keep.source = TRUE) : >>> > > <text>:26:2: unexpected ')' >>> > > 25: >>> > > 26: 2) >>> > > ^ >>> > > >>> > > And the subset of the data.... >>> > > >>> > > row.names = c(NA, 6L), class = "data.frame") >>> > > >>> > > Best, >>> > > >>> > > Spencer >>> > > >>> > > >>> > > On Tue, Jun 25, 2019 at 2:25 PM Rui Barradas >>> > <ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt> >>> > > <mailto:ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt>>> >>> wrote: >>> > > >>> > > Hello, >>> > > >>> > > No I wasn't expecting a very large file. >>> > > Try to make a reproducible example. If the problem seems to >>> > be with the >>> > > sapply/strsplit post a subset of the data like just some of >>> the >>> > > colnames: >>> > > >>> > > colnames(meth)[1:10] >>> > > >>> > > >>> > > This would allow us to run the code you are having trouble >>> with. >>> > > >>> > > >>> > > Hope this helps, >>> > > >>> > > Rui Barradas >>> > > >>> > > Às 17:36 de 25/06/19, Spencer Brackett escreveu: >>> > > > The result of dput(head(meth)) is a very large data >>> > table/listing of >>> > > > data by category of what I presume to be the data from >>> the two >>> > > TCGA .txt >>> > > > files I referenced previously. Is this the output you >>> were >>> > expecting? >>> > > > >>> > > > On Tue, Jun 25, 2019 at 12:19 PM Rui Barradas >>> > > <ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt> >>> > <mailto:ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt>> >>> > > > <mailto:ruipbarra...@sapo.pt <mailto: >>> ruipbarra...@sapo.pt> >>> > <mailto:ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt>>>> >>> wrote: >>> > > > >>> > > > Hello, >>> > > > >>> > > > 1) That error comes from not closing }) after the >>> paste() >>> > > instruction. >>> > > > The complete statement would be >>> > > > >>> > > > >>> > > > colnames(meth) = sapply(colnames(meth), function(i){ >>> > > > c1 = strsplit(i, split ='\\', fixed = T)[[1]] >>> > > > c1[4] = paste(strsplit(c1[4],split = "",fixed = >>> > > > T)[[1]][1:2],collapse >>> > > > = "") >>> > > > paste(c1,collapse = ".") >>> > > > }) >>> > > > >>> > > > >>> > > > 2) Can you post the output of the following? >>> > > > >>> > > > dput(head(meth)) >>> > > > >>> > > > >>> > > > Hope this helps, >>> > > > >>> > > > Rui Barradas >>> > > > >>> > > > Às 16:58 de 25/06/19, Spencer Brackett escreveu: >>> > > > > The following is what I have implemented thus >>> far... >>> > > > > >>> > > > > The file object for the two files listed in lines >>> > 1-2 was >>> > > set in my >>> > > > > working directory, and are under the folder >>> > "Vakul's GBM >>> > > Code"... >>> > > > hence >>> > > > > the source of the odd 'prefix' for .txt files >>> shown >>> > > > > >>> > > > > >library(data.table)>.anno = >>> > as.data.frame(fread(file = >>> > > > "~Vakul's GBM >>> > > > > Code/mapper.txt", sep ="\t", header = T)) >>> > > > > >meth = read.table(file = "~Vakul's GBM >>> Code/GBM.txt", >>> > > sep ="\t", >>> > > > > header = T, row.names = 1) >>> > > > > >meth = as.matrix(meth) >>> > > > > >>> > > > > ## the loop just formats the methylation column >>> > names to >>> > > match >>> > > > format ## >>> > > > > colnames(meth) = sapply(colnames(meth), >>> function(i){ >>> > > > > c1 = strsplit(i,split ='\\', fixed = T)[[1]] >>> > > > > c1[4] = paste(strsplit(c1[4],split = "",fixed = >>> > > > T)[[1]][1:2],collapse >>> > > > > = "") >>> > > > > paste(c1,collapse = ".") >>> > > > > >>> > > > > Rendering reprex... >>> > > > > Error in parse(text = x, keep.source = TRUE) : >>> > > > > <text>:28:0: unexpected end of input >>> > > > > >>> > > > > Best, >>> > > > > >>> > > > > Spencer >>> > > > > >>> > > > > >>> > > > > >>> > > > > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett >>> > > > > <spbracket...@saintjosephhs.com >>> > <mailto:spbracket...@saintjosephhs.com> >>> > > <mailto:spbracket...@saintjosephhs.com >>> > <mailto:spbracket...@saintjosephhs.com>> >>> > > > <mailto:spbracket...@saintjosephhs.com >>> > <mailto:spbracket...@saintjosephhs.com> >>> > > <mailto:spbracket...@saintjosephhs.com >>> > <mailto:spbracket...@saintjosephhs.com>>> >>> > > > <mailto:spbracket...@saintjosephhs.com >>> > <mailto:spbracket...@saintjosephhs.com> >>> > > <mailto:spbracket...@saintjosephhs.com >>> > <mailto:spbracket...@saintjosephhs.com>> >>> > > > <mailto:spbracket...@saintjosephhs.com >>> > <mailto:spbracket...@saintjosephhs.com> >>> > > <mailto:spbracket...@saintjosephhs.com >>> > <mailto:spbracket...@saintjosephhs.com>>>>> >>> > > > > wrote: >>> > > > > >>> > > > > Mr. Barradas, >>> > > > > >>> > > > > I got the same "output" as before, which is >>> the + >>> > > indicating that >>> > > > > the expression is incomplete (according to >>> some >>> > R users >>> > > > response in >>> > > > > this chain). >>> > > > > >>> > > > > Should the argument perhaps be c1 = >>> strsplit(i, >>> > split >>> > > = '\\', >>> > > > fixed >>> > > > > = T)[[1]] .... thereby eliminating the "." ? >>> > > > > The reprex and error message as the result of >>> > this is >>> > > the same as >>> > > > > the previous one I sent. >>> > > > > >>> > > > > I will send a more detailed description of >>> what >>> > code I >>> > > have >>> > > > done so >>> > > > > far for context. >>> > > > > >>> > > > > Best, >>> > > > > >>> > > > > Spencer >>> > > > > >>> > > > > On Tue, Jun 25, 2019 at 11:30 AM Rui Barradas >>> > > > <ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt> >>> > <mailto:ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt>> >>> > > <mailto:ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt> >>> > <mailto:ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt>>> >>> > > > > <mailto:ruipbarra...@sapo.pt >>> > <mailto:ruipbarra...@sapo.pt> >>> > > <mailto:ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt>> >>> > <mailto:ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt> >>> > > <mailto:ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt >>> >>>>> >>> > > > wrote: >>> > > > > >>> > > > > Hello, >>> > > > > >>> > > > > Maybe with >>> > > > > >>> > > > > c1 = strsplit(i, split = '\\.', fixed = >>> T)[[1]] >>> > > > > >>> > > > > instead of split = '.' >>> > > > > >>> > > > > The dot is a metacharacter that matches >>> any >>> > > character so >>> > > > it has >>> > > > > to be >>> > > > > escaped. >>> > > > > >>> > > > > Hope this helps, >>> > > > > >>> > > > > Rui Barradas >>> > > > > >>> > > > > Às 16:11 de 25/06/19, Spencer Brackett >>> > escreveu: >>> > > > > > c1 = strsplit(i,split ='.', fixed = >>> T)[[1]] >>> > > > > >>> > > > >>> > > >>> > >>> >> [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.