Re: [R] Error: unexpected symbol in [with read.table]

2015-06-26 Thread Kate Ignatius
certainly not wisdom." >-- Clifford Stoll > > > On Fri, Jun 26, 2015 at 10:58 AM, Kate Ignatius > wrote: >> "reading in a tab delimited file using args" >> >> What I mean by that is that I'm using a bash script to call in an R >> script and using the

[R] Error: unexpected symbol in [with read.table]

2015-06-26 Thread Kate Ignatius
When reading in a tab delimited file using args I keep getting the error: Error: unexpected symbol in "Name index" Execution halted The code is this: a <- read.table(args[1],sep="\t",header=T, stringsAsFactors=F) When inputting the file directly, as follows, this produces no errors: a <- read

Re: [R] Converting unique strings to unique numbers

2015-05-29 Thread Kate Ignatius
> for (j in 2:4) { > data[[j]] <- match(data[[j]], uniqStrings, nomatch = 0L) > } > data > } > > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Fri, May 29, 2015 at 9:58 AM, Kate Ignatius > wrote: >> >> I have a pe

[R] Converting unique strings to unique numbers

2015-05-29 Thread Kate Ignatius
I have a pedigree file as so: X0001 BYX859 0 0 2 1 BYX859 X0001 BYX894 0 0 1 1 BYX894 X0001 BYX862 BYX894 BYX859 2 2 BYX862 X0001 BYX863 BYX894 BYX859 2 2 BYX863 X0001 BYX864 BYX894 BYX859 2 2 BYX864 X0001 BYX865 BYX894 BYX859 2 2 BYX865 And I was hoping to change

Re: [R] Error importing data - wrapping?

2015-05-09 Thread Kate Ignatius
.OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > On May 9, 2015 7:59:31 AM PDT, Kate Ignatius wrote: >>I have some data that I've trouble importing..

Re: [R] Error importing data - wrapping?

2015-05-09 Thread Kate Ignatius
blank fields are implicitly added. See 'Details'. > > > -- > Don MacQueen > > Lawrence Livermore National Laboratory > 7000 East Ave., L-627 > Livermore, CA 94550 > 925-423-1062 > > > > > > On 5/9/15, 7:59 AM, "Kate Ignatius" wr

[R] Error importing data - wrapping?

2015-05-09 Thread Kate Ignatius
I have some data that I've trouble importing... A B C D E A 1232 0.565 B 2323 0.5656 0.5656 0.5656 C 2323 0.5656 D 2323 0.5656 E 2323 0.5656 F 2323 0.5656 G 2323 0.5656 G 2323 0.5656 0.5656 0.5656 When I input the data it seems to go like this: SampleID ItemB ItemC ItemD ItemE A 1232 0.565 B 232

[R] Grep out columns using a list of strings

2015-05-08 Thread Kate Ignatius
Hi, I have a list of 150 strings, say, ap,: aajkss dfghjk sdfghk ... xxcvvn And I would l like to grep out these strings from column names in another file, af,. I've tried the following but none seem to work: aps <- af[,grep(ap, colnames(af), value=TRUE)] aps <- af[,grep(ap, colnames(af), va

[R] Summing certain values within columns that satisfy a certain condition

2015-02-26 Thread Kate Ignatius
Hi, Supposed I had a data frame like so: A B C D 0 1 0 7 0 2 0 7 0 3 0 7 0 4 0 7 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 5 0 5 1 5 0 4 1 5 0 8 4 7 0 0 3 0 0 0 3 4 0 0 3 4 0 0 0 5 0 2 0 6 0 0 4 0 0 0 4 0 0 0 4 0 For each row, I want to count how many max column values appear to adventurely get the

Re: [R] grepping out columns

2015-02-18 Thread Kate Ignatius
ot;", columns[sa_ind]) > days <- paste0(days,"$") > selected <- lapply(days, function(x) grep(x,columns)) > selected <- sort(unique(unlist(all_ind))) > > columns[selected] > [1] "SA_TUES" "SA_MON" "CH_TUES" "CH_MON" &q

[R] grepping out columns

2015-02-18 Thread Kate Ignatius
Hi, I've got a complicated grep problem (or not)... I currently have a file with the headings as follows: DAY MONTH YEAR SA_TUES SA_MON SU_WED CH_TUES CH_WED CH_MON AR_TUES AR_WED AR_MON SA_THUR SU_FRI CH_THUR CH_FRI AR_THUR AR_FRI I want to grep out all columns that have SA at the beginning of

[R] Paste every two columns together

2015-01-28 Thread Kate Ignatius
I have genetic data as follows (simple example, actual data is much larger): comb = ID1 A A T G C T G C G T C G T A ID2 G C T G C C T G C T G T T T And I wish to get an output like this: ID1 AA TG CT GC GT CG TA ID2 GC TG CC TG CT GT TT That is, paste every two columns together. I have this

Re: [R] rle with data.table - is it possible?

2015-01-03 Thread Kate Ignatius
9: AA AA RA C 3 300 >>> 10: AA RRRR C 3 302 >>> 11: AA RRRA C 2 200 >>> 12: AA RRRR C 2 213 >>> 13: AA AAAA C

Re: [R] rle with data.table - is it possible?

2015-01-02 Thread Kate Ignatius
, David Winsemius wrote: > >> On Jan 1, 2015, at 5:07 PM, Kate Ignatius wrote: >> >> Apologies - mix up of syntax all over the place, a habit of mine. The >> last line was in there because of code beforehand so it really doesn't >> need to be there. Here is t

Re: [R] rle with data.table - is it possible?

2015-01-01 Thread Kate Ignatius
eriesO.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > On January 1, 2015 4:16:52 AM PST, Kate

Re: [R] rle with data.table - is it possible?

2015-01-01 Thread Kate Ignatius
ld > 1: AA RRRA A 2 20 > 2: AA RRRR A 2 21 > 3: AA AAAA B 4 55 > 4: AA AAAA B 4 55 > 5: RA AARR B 0 55 > 6: RR AARR B

Re: [R] rle with data.table - is it possible?

2014-12-31 Thread Kate Ignatius
correct code: childseg<-0 x:=sumchild <-0 span<-rle(x)$lengths[rle(x)$values==TRUE childseg[x]<-rep(seq_along(span), times = span) childseg[childseg == 0]<-'' On Thu, Jan 1, 2015 at 1:56 AM, Kate Ignatius wrote: > Is it possible to add the following code or similar

Re: [R] rle with data.table - is it possible?

2014-12-31 Thread Kate Ignatius
RA A 2 20 > 2: AA RRRR A 2 21 > 3: AA AAAA B 4 55 > 4: AA AAAA B 4 55 > 5: RA AARR B 0 55 > 6: RR AARR B 4 55 >

[R] rle with data.table - is it possible?

2014-12-30 Thread Kate Ignatius
I'm trying to use both these packages and wondering whether they are possible... To make this simple, my ultimate goal is determine long stretches of 1s, but I want to do this within groups (hence using the data.table as I use the "set key" option. However, I'm I'm not having much luck making thi

Re: [R] Printing/Generating/Outputting a Table (Not Latex)

2014-12-09 Thread Kate Ignatius
ay pdf files is what >> belongs there. >> >> On Macintosh we can avoid knowing by using 'open', which means use the >> system standard. >> I don't know what the linux equivalent is, either the exact program or >> the instruction to use the standard

Re: [R] Printing/Generating/Outputting a Table (Not Latex)

2014-12-09 Thread Kate Ignatius
ting the options. > the latex function doesn't do pdflatex (by default it does regular > latex) unless you set the options > as I indicated. > > On Tue, Dec 9, 2014 at 3:11 PM, Kate Ignatius wrote: >> Ah yes, you're right. >> >> The log has this error: >>

Re: [R] Printing/Generating/Outputting a Table (Not Latex)

2014-12-09 Thread Kate Ignatius
.OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > On December 9, 2014 8:43:02 AM PST, Kate Ignatius > wrote: >>Thanks! I do get several errors though when running on Linux. >> >>Running your code, I get this: >> >

Re: [R] Printing/Generating/Outputting a Table (Not Latex)

2014-12-09 Thread Kate Ignatius
:\\progra~2\\Adobe\\Reader~1.0\\Reader\\AcroRd32.exe') > ## 64 bit windows > > ## Linux > ## I don't know the xdvicmd value > > > ## this works on all R systems > library(Hmisc) > tmp <- matrix(1:9,3,3) > tmp.dvi <- dvi(latex(tmp)) > print.default(tmp

[R] Printing/Generating/Outputting a Table (Not Latex)

2014-12-08 Thread Kate Ignatius
Hi, I have a simple question. I know there are plenty of packages out there that can provide code to generate a table in latex. But I was wondering whether there was one out there where I can generate a table from my data (which ever way I please) then allow me to save it as a pdf? Thanks K.

[R] recoding genetic information using gsub

2014-12-05 Thread Kate Ignatius
I have genetic information for several thousand individuals: A/T T/G C/G etc For some individuals there are some genotypes that are like this: A/, C/, T/, G/ or even just / which represents missing and I want to change these to the following: A/ A/. C/ C/. G/ G/. T/ T/. / ./. /A ./A /C ./C /G

Re: [R] grep won't work finding one column

2014-10-14 Thread Kate Ignatius
neer (Solar/BatteriesO.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > On October 14, 2014 7:23:55 AM PDT, Kate Ignatius > wrote: >>I'm having

Re: [R] grep won't work finding one column

2014-10-14 Thread Kate Ignatius
T RA A/A AA T/G RA it will have a problem grepping out this single column. On Tue, Oct 14, 2014 at 10:38 AM, John McKown wrote: > On Tue, Oct 14, 2014 at 9:23 AM, Kate Ignatius > wrote: >> I'm having an issue with grep: >> >> I have numerous columns that end with .a

[R] grep won't work finding one column

2014-10-14 Thread Kate Ignatius
I'm having an issue with grep: I have numerous columns that end with .at... when I use grep like so: df[,grep(".at",colnames(df))] it works fine. When I have one column that ends with .at, it does not work. Why is that? As this is loop with varying number of columns ending in .at I would like

Re: [R] Help with a function [along columns]

2014-10-13 Thread Kate Ignatius
something working but I'm having trouble with the gt part... I'm getting the error: object of type 'closure' is not subsettable. The vcf is my original file that I want to match with so not sure whether this a problem. On Mon, Oct 13, 2014 at 4:46 PM, Kate Ignatius wrote: > Hi

[R] Help with a function [along columns]

2014-10-13 Thread Kate Ignatius
Hi all, I need help with a function. I'm trying to write a function to apply to varying number of columns in a lot of files - hence the function... but I'm getting stuck. Here it is: gt<- function(x) { alleles <- sapply(x, function(.) strsplit(as.character(.), "/")) gt <- apply(x, funct

Re: [R] How to check to see if a variable is within a range of another variable

2014-10-01 Thread Kate Ignatius
u have illustrated > in your 'eventual outcome'). Anyhow, it may be enough to allow you to get > there. > > HTH > > Peter Alspach > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of K

[R] How to check to see if a variable is within a range of another variable

2014-10-01 Thread Kate Ignatius
Is there an easy way to check whether a variable is within +/- 10% range of another variable in R? Say, if I have a variable 'A', whether its in +/- 10% range of variable 'B' and if so, create another variable 'C' to say whether it is or not? Is there a function that is able to do that? eventua

Re: [R] if else statement in loop

2014-09-29 Thread Kate Ignatius
is column X$IID1new != '' does not exist in X > > Here you clearly ask for nonexistent column, and why the heck you want to > select column by number of rows? > >> as.character(as.matrix(X[,(2*nrow(X)+1)])) > Error in `[.data.frame`(X, , (2 * nrow(X) + 1)) : >

[R] if else statement in loop

2014-09-28 Thread Kate Ignatius
I have two data frames For simplicity: X= V1 V2 V3 V4 V5 V6 samas4 samas5 samas6 samas4_father samas5_mother samas6_sibling samas4 samas5 samas6 samas4_father samas5_mother samas6_sibling samas4 samas5 samas6 samas4_father samas5_mother samas6_sibling Y= FID IID FAM01 samas4 FAM01 samas5 FAM0

Re: [R] Ifelse statement on a factor level data frame

2014-09-28 Thread Kate Ignatius
ledge > is certainly not wisdom." > Clifford Stoll > > > > > On Sun, Sep 28, 2014 at 6:38 AM, Kate Ignatius > wrote: >> Strange that, >> >> I did put everything with as.character but all I got was the same... >> >> class of dbpmn[,2]) = factor &g

Re: [R] Ifelse statement on a factor level data frame

2014-09-28 Thread Kate Ignatius
its all about factors and data frames and characters... K. On Sun, Sep 28, 2014 at 1:15 AM, Jim Lemon wrote: > On Sun, 28 Sep 2014 12:49:41 AM Kate Ignatius wrote: >> Quick question: >> >> I am running the following code on some variables that are factors: >> >> dbp

[R] Ifelse statement on a factor level data frame

2014-09-27 Thread Kate Ignatius
Quick question: I am running the following code on some variables that are factors: dbpmn$IID1new <- ifelse(as.character(dbpmn[,2]) == as.character(dbpmn[,(21)]), dbpmn[,20], '') Instead of returning some value it gives me this: c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) Playing around wi

[R] ggplot2/heat map/duplicated level problem

2014-08-17 Thread Kate Ignatius
Hi, I hope I can explain my problem clearly I have a plink output file that I want to graph a heat map of the PI_HAT estimates. I have the following code that I has worked in the past but this time I'm getting the error: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else

Re: [R] data.table/ifelse conditional new variable question

2014-08-16 Thread Kate Ignatius
3456 sibling 349 0 > #2702.3 2702 9980 sibling 349 0 > #3064.4 3064 3 father 0 0 > #3064.5 3064 4 mother 0 0 > #3064.6 3064 5 sibling 4 3 > #3064.7 306486 sibling 4 3 > #

Re: [R] data.table/ifelse conditional new variable question

2014-08-16 Thread Kate Ignatius
Sample.ID[father] > if(sum(mother) == 0) > l$MID[l$Relationship == 'sibling'] <- 0 > else l$MID[l$Relationship == 'sibling'] <- l$Sample.ID[mother] > l > })) > > It is assumed that when either parent is not available the M/PID is 0. > > Best, >

Re: [R] data.table/ifelse conditional new variable question

2014-08-16 Thread Kate Ignatius
ccount for this? On Sat, Aug 16, 2014 at 8:02 PM, Kate Ignatius wrote: > Thanks! > > I think I know what is being done here but not sure how to fix the > following error: > > Error in l$PID[l$\Relationship == "sibling"] <- l$Sample.ID[father] : > replacement has le

Re: [R] data.table/ifelse conditional new variable question

2014-08-16 Thread Kate Ignatius
with(l, Relationship == 'father') > mother <- with(l, Relationship == 'mother') > l$PID[l$Relationship == 'sibling'] <- l$Sample.ID[father] > l$MID[l$Relationship == 'sibling'] <- l$Sample.ID[mother] > l > })) > res > > HTH

[R] data.table/ifelse conditional new variable question

2014-08-16 Thread Kate Ignatius
Hi, I have a data.table question (as well as if else statement query). I have a large list of families (file has 935 individuals that are sorted by famiy of varying sizes). At the moment the file has the columns: SampleID FamilyID Relationship To prevent from having to make a pedigree file by

[R] Layout of two graphs on a page...

2014-06-21 Thread Kate Ignatius
I'm trying to have a layout of two graphs on a page... this has worked before... but I changed up the way I do my venn diagrams so now instead of the Venn Diagram being at the bottom of the page below the bar/line graph it takes up the whole page and its overlays the bar/line graph placed on the to

Re: [R] counting the number of rows that satisfy a certain criteria

2014-06-21 Thread Kate Ignatius
Thanks! On Sat, Jun 21, 2014 at 11:05 AM, Jorge I Velez wrote: > Hi Kate, > > You could try > > sum(X[, 1] == 1 & X[, 2] == 1) > > where X is your data set. > > HTH, > Jorge.- > > > > On Sun, Jun 22, 2014 at 12:57 AM, Kate Ignatius > wrote: >

[R] counting the number of rows that satisfy a certain criteria

2014-06-21 Thread Kate Ignatius
I have 4 columns, and about 300K plus rows with 0s and 1s. I'm trying to count how many rows satisfy a certain criteria... for instance, how many rows are there that have the first column == 1 as well as the second column == 1. I've tried using rowSums and colSums but it keeps giving me this type

[R] Error in merge [negative length vectors are not allowed]

2014-06-16 Thread Kate Ignatius
Hi All, I'm trying to merge two files together using: combinedfiles <- merge(comb1,comb2,by=c("Place","Stall","Menu")) comb1 is about 2 million + rows (158MB) and comb2 is about 600K+ rows (52MB). When I try to merge using the above syntax I get the error: Error in merge.data.frame(comb1, comb

[R] Using reduce to merge multiple files

2014-06-12 Thread Kate Ignatius
I have a list of files that I have called like so: main_dir <- '/path/to/files/' directories <- list.files(main_dir, pattern = '[[:alnum:]]', full.names=T) filenames <- list.files(file.path(directories,"/tmpdir/"), pattern = '[[:alnum:][:punct:]]_eat.txt+$', recursive = TRUE, full.names=T) This

[R] Adding segments to a dot plot in ggplot2

2014-05-22 Thread Kate Ignatius
I'm trying to plot a GWAS (in you will) with lined segments representing an overall p-value for each gene. Here is my code: skatg <- ggplot(comm, aes(x = position,y = p, colour = grey)) + geom_point(size = 0.75) + geom_segment(data=rare, aes(x = txStart,

Re: [R] Mean of colMeans

2014-05-21 Thread Kate Ignatius
n't provide reproducible example so who knows. > > R> set.seed(1) > R> x <- data.frame(matrix(runif(150), ncol=10)) > R> # col is a function, so not a good name > R> col <- colMeans(x) > R> mean(col) > [1] 0.5119 > > It's polite to include th

[R] Mean of colMeans

2014-05-21 Thread Kate Ignatius
Hi All, I've successfully gotten out the colMeans for 60 columns using: col <- colMeans(x, na.rm = TRUE, dims = 1) My next question is: is there a way of getting a mean of all the column means (ie a mean of a mean)? Thanks! __ R-help@r-project.org ma

[R] Manipulating x axis using scale_x_continuous (but a factor is used). Is there a work around?

2014-04-06 Thread Kate Ignatius
My code that I've used is: mcgc <- ggplot(sam, aes(x = person,y = m, colour = X)) + geom_point(size = 0.75) + scale_colour_gradient2(high="red", mid="green", limits=c(0,1), guide = "colourbar") + geom_hline(aes(yintercept = mad, linetype =

[R] Colour of geom_hline is not correct in legend

2014-04-06 Thread Kate Ignatius
I've used geom_point and geom_hline in ggplot2 and have gotten satisfactory legends for both. However, I have one black line and one blue line in the figure but in the legend they are both black - how can I correct this in the legend to be the right colors? mcgc <- ggplot(sam, aes(x = m,y = a

[R] Recoding in R conditioned on a certain value.

2014-04-05 Thread Kate Ignatius
I'm trying to work out the average of a certain value by chromosome. I've done the following, but it doesn't seem to work: Say, I want to find average AD for chromosome 1 only and paste the value next to all the positions on chromosome 1: sam$mmad[sam$chrom == '1'] <- (sam$ad)/(colSums(sam[c(1:nr

[R] Setting alternative x-axis breaks using gglpot2

2014-04-05 Thread Kate Ignatius
I'm not doing a Manhattan plot, but plotting AD (coloured by DP) along the genome: points <- ggplot(sam,aes(x = midpoint,y = ad, colour = dp, size = 3)) + geom_point() + scale_y_continuous(breaks=c(0,20,30,40)) + labs(x = "chr",y = "ad") + scale_colour_gradient2(high="red", mid="green")