[R] Decompose df1 into another df2 based on values in df1

2021-05-26 Thread Adrian Johnson
Hello, I am trying to convert a df (given below as d1) into df2 (given below as res). I tried using loops for each row. I cannot get it right. Moreover the df is 25 x 500 in dimension and I cannot get it to work. Could anyone help me here please. Thanks. Adrian. d1 <- structure(list(S1 =

[R] pheatmap - clustering of select columns

2019-03-08 Thread Adrian Johnson
Dear group, In pheatmap, is it possible to cluster select colmns. For example, in a matrix of 10 rows and 20 columns. I want to cluster only those columns 1-10 and cluster rows. Similarly, retaining the same row clustering resulted from clustering of columns 1-10, I want to enforce clustering of 11

[R] faster execution of for loop in Fishers test

2019-02-11 Thread Adrian Johnson
Dear group, I have two large matrices. Matrix one: is 24776 x 76 (example toy1 dput object given below) Matrix two: is 12913 x 76 (example toy2 dput object given below) Column names of both matrices are identical. My aim is: a. Take each row of toy2 and transform vector into UP (>0) and DN (

Re: [R] (no subject)

2019-02-11 Thread Adrian Johnson
Pardon me, I forgot to add subject line. -Adrian. On Sun, Feb 10, 2019 at 3:49 PM Adrian Johnson wrote: > > Dear group, > > I have two large matrices. > > Matrix one: is 24776 x 76 (example toy1 dput object given below) > > Matrix two: is 12913 x 76 (example toy2

[R] (no subject)

2019-02-10 Thread Adrian Johnson
Dear group, I have two large matrices. Matrix one: is 24776 x 76 (example toy1 dput object given below) Matrix two: is 12913 x 76 (example toy2 dput object given below) Column names of both matrices are identical. My aim is: a. Take each row of toy2 and transform vector into UP (>0) and DN (

Re: [R] data transformation

2019-01-20 Thread Adrian Johnson
I apologize, I forgot to mention another key operation. in my matrix -1 to <0 has a different meaning while values between >0 to 1 has a different set of meaning. So If I do logit transformation some of the positives becomes negative (values < 0.5 etc.). In such case, the resulting transformed ma

[R] data transformation

2019-01-20 Thread Adrian Johnson
Dear group, My question, perhaps is more of a statistical question using R I have a data matrix ( 400 x 400 normally distributed) with data points ranging from -1 to +1.. For certain clustering algorithms, I suspect the tight data range is not helping resolving the clusters. Is there a way to tran

Re: [R] How to get CI from surfit object in survival

2017-08-26 Thread Adrian Johnson
gt; -- Bert > > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Sat, Aug 26, 2017 at 5:18 PM, Adrian

Re: [R] How to get CI from surfit object in survival

2017-08-26 Thread Adrian Johnson
hich case you should learn them now; see > ?help -- or have I misunderstood your query? > > Cheers, > Bert > > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley B

[R] How to get CI from surfit object in survival

2017-08-26 Thread Adrian Johnson
Hi I am not sure hiw to get thr CI from summary function on the survfit object. I can get the percent survival for 2 years from survfit object but I dont get Confidence intervals Could anyone suggest a hint Thanks Adrian [[alternative HTML version deleted]] __

[R] test for proportion or concordance

2017-08-03 Thread Adrian Johnson
Hello group, my question is deciding what test would be appropriate for following question. An experiment 'A' yielded 3200 observations of which 431 are significant. Similarly, using same method, another experiment 'B' on a different population yielded 2541 observations of which 260 are significa

[R] tests for significance on conditional inference trees from party package

2016-12-13 Thread Adrian Johnson
Dear group, Please allow me to ask a naive question and pardon if it is qualified as stupid question. I am using party package to classify covariates and predict distribution of survival times for the classified variables. Typically I have a matrix of covariates (columns) including outcome data (o

[R] Clustering methods for data that has bimodal distribution

2016-12-04 Thread Adrian Johnson
Dear group, pardon me for a naive question. I have data matrix (11K rows , 4K columns). The data range is between -1 to 1. Not strictly integers, but real numbers with at least place values in millionths. The data distribution is peculiar (if I do plot(density(myMatrix)), I get nice bimodal curve

[R] replace items in vector with character based on logical operator

2016-11-12 Thread Adrian Johnson
Hi group, I have a vector of numeric items and I want to replace based on logical operator (> or <) with 'up', 'down' or 'nochange' The way I am doing works sometimes and does not work sometime. I dont understand the problem. In this example, that works for condition DN first, gets over-written

[R] pheatmap - clustering on some columns only

2016-10-14 Thread Adrian Johnson
Dear group, I have a matrix (300 rows X 475columns). The data is divided into many classes. For examples: 475 columns are split into 3 categories - A, B and C Is it possible to force clustering of columns in A followed by B and C. I do not want to cluster whole matrix. I want to cluster by 3 categ

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adrian Johnson
As Dr.Murdoch suggested, transformation of row 2 is important to make sense in graphical depiction. Thanks to all. On Wed, Oct 12, 2016 at 4:25 PM, Adrian Johnson wrote: > Hello Dr. Carlson, > thanks for the tip. It is exactly what I am looking for. > > I see the trick lies in >

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adrian Johnson
David L Carlson > Department of Anthropology > Texas A&M University > College Station, TX 77840-4352 > > > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Adams, Jean > Sent: Wednesday, October 12, 2016 12:44 PM > To: Adrian Johnso

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adrian Johnson
Thanks Duncan. I am sorry I cannot scale second row (d[2,]). I was looking for a way to plot d[2,] values next to d[1,] with a right side axis=4 on right side. -2,-1,0,1,2 thanks Adrian On Wed, Oct 12, 2016 at 12:42 PM, Duncan Murdoch wrote: > On 12/10/2016 12:20 PM, Adrian Johnson wr

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adrian Johnson
, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L, > 528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN", > "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23" > ))) > plot(m["

[R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adrian Johnson
Dear group, I have been struggling to barplot two different measurements from one subject. These two measures differ in range. I want to plot row 1 axis on left side and row 2 values on right side. For a given column I want to plot GN and CN next to each other. my dput code is below : structure

[R] pheatmap breaks

2016-08-19 Thread Adrian Johnson
Hi group: I tried multiple times cannot understand the breaks to work for my heatmap. I am using following way: pheatmap(chxx, cluster_cols=FALSE, annotation_col=annotcols, annotation_colors=anno_colors, col=colorRampPalette(c("dark blue", "white", "#ff"))(34), show_colnames=F) > max(chxx)

Re: [R] remove rows based on row mean

2016-08-18 Thread Adrian Johnson
ated(sm$Gene)),] > > Jim > > > On Fri, Aug 19, 2016 at 7:33 AM, Adrian Johnson > wrote: >> Hi Group, >> I have a data matrix sm (dput code given below). >> >> I want to create a data matrix with rows with same variable that have >> higher mean. >

[R] remove rows based on row mean

2016-08-18 Thread Adrian Johnson
Hi Group, I have a data matrix sm (dput code given below). I want to create a data matrix with rows with same variable that have higher mean. > sm Gene GSM529305 GSM529306 GSM529307 GSM529308 1A1BG 6.57 6.72 6.83 6.69 2A1CF 2.91 2.80 3.08 3.00

[R] RGL library loading issues

2016-08-05 Thread Adrian Johnson
Dear group: I installed rgl on my mac through terminal. I used install.packages(rgl) and selected 118 server option. Installation went well until, I get message checking if installed packages working and nothing happens. I opened another terminal window and types library(rgl) and I see my X11qu

[R] generate a vector of random numbers within confines of certain parameters

2016-08-02 Thread Adrian Johnson
Dear group, I am trying to generate a vector of random numbers for 20K observation. however, I want to generate numbers (with 6 decimal places) within the range of Std. Dev : 2-3 mean : 4-6 Is there a method to generate numbers with 6 decimal places under these parameters thank you. Adrian __

Re: [R] if else condition - help

2016-05-22 Thread Adrian Johnson
gt; A 0 0 0 0 > B 1 0 0 0 > C 0 -1 0 0 > D -1 1 -1 -1 > > On Sun, May 22, 2016 at 2:00 PM Adrian Johnson > wrote: >> >> Hi group: >> I am having difficulty with if else condition. I kindly request some help. >> >> I have a matrix k &

[R] if else condition - help

2016-05-22 Thread Adrian Johnson
Hi group: I am having difficulty with if else condition. I kindly request some help. I have a matrix k > k C1 C2 C3 C4 A 0.09902175 -0.1083887 0.2018689 -0.3546167 B 1.60623838 -1.4167034 0.9076373 -0.3161138 C -0.10433133 -1.7060911 -0.4030050 1.0153297 D

[R] sorting matrix by sets rows

2016-02-06 Thread Adrian Johnson
Hello: sorry I've been trying to sort a matrix to make waterfall plot using barplot function. I have have 30x5 matrix.Rows are samples and columns are results for a test as numeric vector. I want sort matrix by column. For example, first I want to sort column 1, in decreasing values where col

Re: [R] matrix/df help populate NA

2015-06-14 Thread Adrian Johnson
ames(x2)) >> >> new_x2 <- x2 >> >> for (i in missing) new_x2[[i]] <- NA >> >> new_x2 > Subject AD FH B C > 1 x1 4.3 -2.4 1.3 -2.3 NA NA > 2 x2 2.4 0.1 0.5 -1.4 NA NA > > > > > > Jim Holtman > Data Munger

[R] matrix/df help populate NA

2015-06-13 Thread Adrian Johnson
Dear group: I have two data frames. The column names of the two data frame has some common variables but not identical. my aim is to make 2 DFs more uniform by taking union of both colnames For example: I have x1 and x2 matrices: > x1 SubjectAB CD 1 x1 1.5 -1.3 0.4 -0.2

Re: [R] Combining two data frames

2014-09-19 Thread Adrian Johnson
thanks it works I guess: merge(b1,b2,by='Subject') On Fri, Sep 19, 2014 at 5:03 PM, Uwe Ligges wrote: > See ?merge > > Best, > Uwe Ligges > > > On 19.09.2014 22:58, Adrian Johnson wrote: >> >> Hi: >> Appreciate if I could get some help. >

[R] Combining two data frames

2014-09-19 Thread Adrian Johnson
Hi: Appreciate if I could get some help. I have two data frames. I want to combine these two dfs bases on first column. df1 : SubjectG1 G2G3 A 10 1 0 B 20 220 df2: Subject m1m2 m3 A 20 9 30 B

Re: [R] populating matrix with binary variable after matching data from data frame

2014-08-14 Thread Adrian Johnson
t; if ((n <- length(extraDimnames[[1]])) > 0) { >> x <- rbind(x, array(0, c(n, ncol(x)), dimnames = >> list(extraDimnames[[1]], >> NULL))) >> } >> if ((n <- length(extraDimnames[[2]])) > 0) { >>

Re: [R] populating matrix with binary variable after matching data from data frame

2014-08-13 Thread Adrian Johnson
Hello again. sorry for question again. may be I was not clear in asking before. I don't want to remove rows from matrix, since row names and column names are identical in matrix. I tried your suggestion and here is what I get: > fx <- function(x,x1){ + i <- as.matrix(x1[,c("V1","V2")]) + x[i]

Re: [R] populating matrix with binary variable after matching data from data frame

2014-08-13 Thread Adrian Johnson
wn wrote: > On Tue, Aug 12, 2014 at 7:14 PM, Adrian Johnson > wrote: >> >> Hi: >> sorry I have a basic question. >> >> I have a data frame with two columns: >> > x1 >> V1 V2 >> 1 AKT3TCL1A >> 2 AKTIPVPS41 >> 3

[R] populating matrix with binary variable after matching data from data frame

2014-08-12 Thread Adrian Johnson
Hi: sorry I have a basic question. I have a data frame with two columns: > x1 V1 V2 1 AKT3TCL1A 2 AKTIPVPS41 3 AKTIPPDPK1 4 AKTIP GTF3C1 5 AKTIPHOOK2 6 AKTIPPOLA2 7 AKTIP KIAA1377 8 AKTIP FAM160A2 9 AKTIPVPS16 10 AKTIPVPS18 I have a matrix 1211

[R] map column name in matrix to multiple elements

2014-08-08 Thread Adrian Johnson
Hi: I am requesting help on matrix mapping. I have a matrix that is 5000 rows x 3000 columns in R env. Matrix: A BC D E S1 0.01 0.2 -0.3 0.8-1 S2 -21.4 2.3 3.1-2 S3 -4 -3-2

[R] mutually exclusive events

2014-08-02 Thread Adrian Johnson
Hi: I am trying to identify mutually exclusive events from the following example: Cluster Gene Mutatednot-mutated 1 G1 1 0 1 G2 1 0 1 G3 0 1 1 G4

[R] Creating data frame from individual files

2013-04-03 Thread Adrian Johnson
Dear Group: I have 72 files (.txt). Each file has 2 columns and column 1 is always identical for all 70 files. Each file has 90,799 rows and is standard across all files. I want to create a matrix 40(rows) x 70 columns. I tried : temp = list.files(pattern="*.txt") named.list <- lapply(temp, rea

Re: [R] select duplicate identifier with higher mean across sample columns

2012-11-05 Thread Adrian Johnson
gt; id samp1 samp2 samp2a > A A 120 130150 > C C 101 131151 > D D 110 150130 > E E 132 122122 > F F 123 143143 > > > On Sun, Nov 4, 2012 at 2:25 PM, Adrian Johnson > wrote: >> Hi Group: >> I searched R groups be

[R] select duplicate identifier with higher mean across sample columns

2012-11-04 Thread Adrian Johnson
Hi Group: I searched R groups before posting this question. I could not find the appropriate answer and I do not have clear understanding how to do this in R. I have a data frame with duplicated row identifiers but with different values across columns. I want to select the identifier with higher i

[R] combining numeric vector and column in a data frame

2012-07-10 Thread Adrian Johnson
Hi: I am trying to map column names of a matrix to another data frame and get values in a different column of data frame I have a matrix m. > my.numeric vec <- m[1,] > my.numeric.vec a b cd ef 2 1 49 10 3 ## my data frame = df1 > df1 fileNametype sta

[R] help with creating a box plot

2012-05-18 Thread Adrian Johnson
Hi: I am looking for some help in making two boxplots next to each other. I have a data like this: N1 T1 N2 T2 N3 T3 N4 T4 ... Nn Tn 7 8.2 4 5 8104 5 . 10 11 I want to have box plot for all Normal samples (N1,N2,N3,N4Nn) and another box plot

Re: [R] range and intersection

2010-03-13 Thread Adrian Johnson
'\t' File2$Y if no : Do nothing. I am only interested in lines that match names in File2 to be printed. I did this in Python but it is far slower. thanks Adrian On Sat, Mar 13, 2010 at 11:55 PM, David Winsemius wrote: > > On Mar 13, 2010, at 11:38 PM,

Re: [R] range and intersection

2010-03-13 Thread Adrian Johnson
;\t' File2$Y. Thanks Adrian On Sat, Mar 13, 2010 at 11:21 PM, David Winsemius wrote: > > On Mar 13, 2010, at 10:14 PM, Adrian Johnson wrote: > >> Hi: >> >> I have a two large files (over 300K lines). >> >> file 1: >> >> Name

[R] range and intersection

2010-03-13 Thread Adrian Johnson
Hi: I have a two large files (over 300K lines). file 1: NameX UK 199 UK 230 UK 139 .. UAE194 UAE 94 File 2: Name XY UK140 180 UK195240 UK304340 I want to select X of File 1 and search if it falls in range of X and Y of Fil

[R] comparing two data.frames

2009-10-29 Thread Adrian Johnson
Dear group, I have two data.frames X and Y identical except for values. > X gene fc A1CF -0.10050677 A2BP1 -2.03093217 A2M -0.09092704 A4GALT 0.04124563 A4GNT -0.10336042 > Y gene fc A1CF -0.085709770 A2BP1 1.058642812 A2M 0.142530426 A4GALT0.0094631

Re: [R] correlation help

2009-09-20 Thread Adrian Johnson
luated was: (y) > for(i in 1:14659){ + k = i+1 + cor.test(d6[i,],d6[k,]) + x = cor.test(d6[i,],d6[k,]) + return(x)} Error: no function to return from, jumping to top level I appreciate your help. thank you. Adrian On Sun, Sep 20, 2009 at 6:17 PM, Adrian Johnson wrote: > thank you jo

[R] correlation help

2009-09-20 Thread Adrian Johnson
Dear group, I have a matrix like the following: Name Sample1sample2sample3 sample4 . sample(n) nm110.5 13.5 30 31 nm2 8 1134 29 nm3 9 10.3 27.8 35 nm(j) I w

Re: [R] t-scores and correlation

2009-07-10 Thread Adrian Johnson
he args list of 'length' being evaluated was: (y) On Fri, Jul 10, 2009 at 4:22 PM, Jorge Ivan Velez wrote: > Dear Adrian, > See ?cor.test. > HTH, > > Jorge > > > On Fri, Jul 10, 2009 at 4:13 PM, Adrian Johnson > wrote: >> >> Hi I have a matrix with

[R] t-scores and correlation

2009-07-10 Thread Adrian Johnson
Hi I have a matrix with samples on columns and variables and their values on rows. I want to calculate correlation (pearson) between a variable and others in rows and obtain t-scores for the variables. how can i do it. thank you. Ad __ R-help@r-project.o

[R] convert data frame values

2008-04-03 Thread Adrian Johnson
Hello: How can I interchange symbols for numeric values in a data frame. > test f s t 1 a 1 -1 2 b 1 -3 3 c -1 1 say I have test d.f . I want to make flip number that are positive to negative and negative to positive only for numerics in column 's' my desired result: > new.test f s t

[R] medians on data frame with duplicated rows

2008-04-02 Thread Adrian Johnson
Dear list: I have a data frame with student name, class he attended and marks for subjects he attended. Students took second exam if they performed badly in their first attempt. I want to consider the test scores where they obtain highest median. there are 6 classes. As a sample case, I will c

[R] Converting a data frame to matrix

2008-03-27 Thread Adrian Johnson
Hello: I have a tab delim file with 100 rows and 100 columns. I have numerical values in this table. What I want is to create an image color map with color gradation. my values range from -5 to 0. max value is 0. to acheive this, I need to convert my data.frame into matrix. I tried following :