[R] please help with "could not find function "ComBat.mc" "

2020-11-11 Thread Yuan Chun Ding
s ComBat.mc function is from an R package "Enmix". When typing library(Enmix), no error message, so the Enmix library is installed.  Can you tell me why I got this e

Re: [R] please help with "could not find function "ComBat.mc" "

2020-11-12 Thread Yuan Chun Ding
Hi Jim, Thank you for the message! Yes, you are right, I contacted Dr. Xu Zongli, he said he removed the ComBat.mc function from the new version. Ding From: Jim Lemon [mailto:drjimle...@gmail.com] Sent: Wednesday, November 11, 2020 5:36 PM To: Yuan Chun Ding Cc: r-help@r-project.org Subject

[R] non-standard reshape from long to wide

2021-01-07 Thread Yuan Chun Ding
Dear R user, I want to reshape a long data frame to wide format, I made the following example files. Can you help me? Thank you, Yuan Chun Ding sample <-c("xr" , "xr" , "fh" , "fh" , "fh" , "uy" , "uy" , "uy"

Re: [R] non-standard reshape from long to wide

2021-01-07 Thread Yuan Chun Ding
t; warnings() Warning messages: 1: In reshapeWide(data, idvar = idvar, timevar = timevar, ... : multiple rows match for Tumor_Sample_Barcode=TCGA-A8-A09Z-01A-11W-A019-09: first taken 2: In reshapeWide(data, idvar = idvar, timevar = timevar, ... : From: Bert Gunter [mailto:bgunter.4...@gmail.

Re: [R] non-standard reshape from long to wide

2021-01-07 Thread Yuan Chun Ding
Hi Rui, Thank you so much!! You code works well and I am looking into the pivot_wider function. Yuan Ding -Original Message- From: Rui Barradas [mailto:ruipbarra...@sapo.pt] Sent: Thursday, January 7, 2021 12:19 PM To: Yuan Chun Ding ; r-help@r-project.org Subject: Re: [R] non

[R] replace zero in a matrix using random numbers

2021-01-08 Thread Yuan Chun Ding
dom numbers across different zero values. If all zero values in one row are replaced by the same 1.13, then sd in that row is zero, causing other problem in the following calculation. Can you help me? Thank you, Yuan chun D

Re: [R] replace zero in a matrix using random numbers

2021-01-08 Thread Yuan Chun Ding
Hi Bert and Rui, Thank you very much! I had thought for every condition of matrix ==0 , rnrom(n=1, 1, 0.1) will randomly generate a number with mean 1 and sd 0.1. Yuan From: Bert Gunter [mailto:bgunter.4...@gmail.com] Sent: Friday, January 8, 2021 2:49 PM To: Yuan Chun Ding Cc: r-help@r

[R] add cex.axis =1.2 to qqunif.plot from lattice library

2021-03-27 Thread Yuan Chun Ding
Dear R user, The following qqunit.plot function generated correct qq plot, however, I want to make axis label (1 ,2 ,.8) have larger size for publication. I tried to add cex.axis =1.2 code following the pch =20, but it does not change size of axis label. I guess lattice library setting is

[R] apply a color range (kind of like a heat map) to the values in each cell of a data frame

2021-06-17 Thread Yuan Chun Ding
Dear R users, I have a numeric table with 140 rows and 30 columns, here I only made partial table, test1, as an example. I want to apply a blue color range to the value in each cell of the data frame test1. I found some R code using DT library. However, I only can see the colored table at m

Re: [R] apply a color range (kind of like a heat map) to the values in each cell of a data frame

2021-06-18 Thread Yuan Chun Ding
HSV or HCL). You may be interested in some of the plotting functions in plotrix that employ color.scale, particularly "size_n_color". Jim On Fri, Jun 18, 2021 at 10:04 AM Yuan Chun Ding wrote: > > Dear R users, > > I have a numeric table with 140 rows and 30 columns, here I only ma

[R] add a variable a data frame to sequentially count unique rows

2021-07-02 Thread Yuan Chun Ding
Hi R users, In this test file, test <- data.frame(group1=c("g1", "g1", "g1", "g2", "g2", "g2", "g2", "g2", "g2"), group2=c("k1", "a2", "a2", "c5", "n6", "n6", "n6", "m10","m10"), count= c( 1, 1,2, 1, 2,

Re: [R] add a variable a data frame to sequentially count unique rows

2021-07-02 Thread Yuan Chun Ding
summarise(Number_of_region = n_distinct(group2)) Ding -Original Message- From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Sent: Friday, July 2, 2021 3:36 PM To: r-help@r-project.org; Yuan Chun Ding ; r-help@r-project.org Subject: Re: [R] add a variable a data frame to sequentia

Re: [R] add a variable a data frame to sequentially count unique rows

2021-07-02 Thread Yuan Chun Ding
2, 1, 2, 2, 2,3,3 )); I want to get count column. the summary count is below. count_test <- test %>% group_by(group1 ) %>%summarise(Number_of_region = n_distinct(group2)) Thank you, Ding -Original Message- From: Bert Gunter [mailto:bgunter.4...@gmail.c

Re: [R] add a variable a data frame to sequentially count unique rows

2021-07-02 Thread Yuan Chun Ding
1,2, 2, 2, 3,3 )); I also thought about removing of duplicates first and then doing a merge. For some reason, I thought one line of code from tidyverse library could do it . Thank You, Ding -Original Message- From: Jeff Newmiller [

Re: [R] add a variable a data frame to sequentially count unique rows

2021-07-02 Thread Yuan Chun Ding
years ago. Ding -Original Message- From: Avi Gross [mailto:avigr...@verizon.net] Sent: Friday, July 2, 2021 5:14 PM To: Yuan Chun Ding ; r-help@r-project.org Subject: RE: [R] add a variable a data frame to sequentially count unique rows Ding, Just to get you to stop asking, here is a soluti

[R] data reshape

2019-12-19 Thread Yuan Chun Ding
Hi R users, I have a folder (called genotype) with 652 files; the file names are GTEX-1A3MV.out, GTEX-1A3MX.out, GTEX-1B8SF.out, etc; in each file, only one column of data without a header as below 201 2/2 238 3/4 245 1/2 . 983255 3/3 983766 None A total of 20528 rows; I need to read al

Re: [R] data reshape

2019-12-20 Thread Yuan Chun Ding
erge all 652 files into one file with VNTRid as first column, 2nd to 653th column are genotype with header #as sample ID, so From: Bert Gunter [mailto:bgunter.4...@gmail.com] Sent: Thursday, December 19, 2019 6:52 PM To: Yuan Chun Ding Cc: r-help@r-project.org Subject: Re: [R] data reshape __

Re: [R] data reshape

2019-12-20 Thread Yuan Chun Ding
Hi Bert, Thank you for the elegant code example. I achieved my goal using lapply function and do.call function together. Reduce function is nicer one and I am looking into it. Ding From: Bert Gunter [mailto:bgunter.4...@gmail.com] Sent: Friday, December 20, 2019 11:47 AM To: Yuan Chun Ding

[R] a simple question

2020-01-01 Thread Yuan Chun Ding
Hi R users, in a Shiny test code, choices = list(1, 2, 3), it generates three components in the choice list, my code works fine and generated tables and plots I want. now I want to modify to choices = list (1, 2, 3, , 5211). list (seq(1, 5211,1) does not work, it generates one component

Re: [R] a simple question

2020-01-01 Thread Yuan Chun Ding
Hi Rolf, Yes, choices = as.list(seq(1,5211,1)) is what I want. Thank you so much, Ding From: Rolf Turner [r.tur...@auckland.ac.nz] Sent: Wednesday, January 1, 2020 3:29 PM To: Yuan Chun Ding; r-help@r-project.org Subject: Re: [R] a simple question

[R] R package for genetic analysis of VNTR (variable number of tandem repeats) genotype data

2020-01-02 Thread Yuan Chun Ding
Hi R users, Does any one know a R package for genetic analysis of VNTR (variable number of tandem repeats) genotype data? For example, performing Hardy Weinberg equilibrium test, calculating heterozygosity and polymorphism information content etc. I am sorry if this question is not relevant to t

Re: [R] adjusted p value, fdr

2020-01-07 Thread Yuan Chun Ding
When you do x1g$fdr, you adjusted for a total of 15568 tests, so FDR is high for those first four entries. When you do p.adjust(pval,method="BH"), you assumed there were only a total of 4 multiple tests in your experiment, so FDR is low. Ding -Original Message- From: R-help [mailto:r

[R] how to archive old shiny applications

2020-03-05 Thread Yuan Chun Ding
Hi R users, We like to use shiny program to share data view between collaborators in different universities. When running shiny, I got the following errors, so I just found that I am allowed to upload up to five applications. I want to remove the first four old applications (not view those pl

Re: [R] how to archive old shiny applications

2020-03-05 Thread Yuan Chun Ding
Thank you for pointing me there. Ding -Original Message- From: peter dalgaard [mailto:pda...@gmail.com] Sent: Thursday, March 05, 2020 2:21 PM To: Yuan Chun Ding Cc: r-help@r-project.org Subject: Re: [R] how to archive old shiny applications That'll be between you and the peopl

[R] find multiple mode

2020-03-15 Thread Yuan Chun Ding
Hi R users, I want to find multiple modes (10, 8, 149) for the following vector. freq =1,2,5,5 10,4,4,8,1,1,8,8,2,4,3,1,2,1,1 138 149 14,1,1; any suggestion? Thank you, Ding -- --

Re: [R] find multiple mode, sorry for not providing enough information

2020-03-15 Thread Yuan Chun Ding
tem4 <-as.data.frame(t(t(table(tem3$VNTR_repeats[,c(1,3)] tem4$Var1 <-as.numeric(as.character(tem4$Var1)) tem4 <-tem4[order(tem4$Var1),] m<- ____ From: Abby Spurdle [spurdl...@gmail.com] Sent: Sunday, March 15, 2020 3:42 PM To: Jim Lemo

Re: [R] find multiple mode

2020-03-15 Thread Yuan Chun Ding
rettyR) >>> Mode(freq) >> [1] "1" >> >> You have a single modal value (1). If there were at most two ones, you >> would have three values (2,4,8) that could be considered multiple >> modes. What you seem to be doing is considering values that are not &g

Re: [R] find multiple mode, sorry for not providing enough information

2020-03-15 Thread Yuan Chun Ding
nal packages. I admit that what I am doing is pretty explorative. On Sun, Mar 15, 2020 at 9:11 PM Yuan Chun Ding mailto:ycd...@coh.org>> wrote: sorry, I just came back. Yes, Abby's understanding is right. > tem4$Var1 [1] 13 4 5 67 8 9 10 11 12 13 14 15

Re: [R] find multiple mode, sorry for not providing enough information

2020-03-16 Thread Yuan Chun Ding
-Original Message- From: Jim Lemon [mailto:drjimle...@gmail.com] Sent: Monday, March 16, 2020 1:10 AM To: Yuan Chun Ding; r-help mailing list Subject: Re: [R] find multiple mode, sorry for not providing enough information [Attention: This email came from an external source. Do not open

Re: [R] find multiple mode, sorry for not providing enough information

2020-03-16 Thread Yuan Chun Ding
ints=TRUE),] -Original Message- From: Abby Spurdle [mailto:spurdl...@gmail.com] Sent: Monday, March 16, 2020 1:57 PM To: Yuan Chun Ding Cc: Jim Lemon; r-help mailing list Subject: Re: [R] find multiple mode, sorry for not providing enough information (Sorry, that was supposed to go to the

[R] row combining 2972 files

2020-03-18 Thread Yuan Chun Ding
Hi R users, I generated 2972 list files in R, each list includes four data frame files , file names for those list file are VNTR13576, VNTR14689, etc. the second data frame in each list has the same 11 column names, but different number of rows. I can combine two dataframes by list2972 <-ls(pa

Re: [R] row combining 2972 files

2020-03-18 Thread Yuan Chun Ding
Hi Bert, Yes, your code works very well. Thank you very much!! Ding From: Bert Gunter [bgunter.4...@gmail.com] Sent: Wednesday, March 18, 2020 1:02 PM To: Yuan Chun Ding Cc: r-help mailing list Subject: Re: [R] row combining 2972 files Untested in the absence

Re: [R] row combining 2972 files

2020-03-18 Thread Yuan Chun Ding
ned <- data.table::rbindlist(keep) HTH, Denes > > should do it. > > > 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" comi

[R] a simple reshape

2020-04-03 Thread Yuan Chun Ding
Hi R users, I want to do a data reshape from long to wide, I thought it was easy using tidyverse spread function, but it did not work well. Can you help me? Thank you, Ding test1 data frame is long file and test2 is the wide file I want to get test1 <- data.frame (vntr1=c("v1","v1", "v2","v2"

Re: [R] a simple reshape

2020-04-03 Thread Yuan Chun Ding
Rui Barradas [ruipbarra...@sapo.pt] Sent: Friday, April 3, 2020 12:08 PM To: Yuan Chun Ding; r-help mailing list Subject: Re: [R] a simple reshape Hello, It's a bit more complicated than you have coded it. I will use pivot_wider, it's now the natural way of doing it. test1 %>

Re: [R] a simple reshape

2020-04-04 Thread Yuan Chun Ding
: Yuan Chun Ding Cc: r-help mailing list Subject: Re: [R] a simple reshape Hi, [For a non-tidyverse solution:] Your problem is ambiguous without a 'time' variable; e.g., why should the answer not be test2 <- data.frame(vntr1=c("v1","v2"),

[R] to create a new variable based on values in other variables

2020-04-07 Thread Yuan Chun Ding
Hi R users, I want to create a new variable, Ravg, in data frame tem2 based on values of two other variables m1 and m2. the condition: if m1 = 23 and m2 =23 then Ravg =23; else if m1 != 23 and m2=23 then Ravg =m1; else if m1 =23 and m2 !=23 then Ravg=m2; else Ravg=average of m1 and m2; the R

Re: [R] to create a new variable based on values in other variables

2020-04-07 Thread Yuan Chun Ding
confused when there are more than two conditions inside of ifelse function. I will look into ifelse function Thank you, Ding From: Thierry Onkelinx [thierry.onkel...@inbo.be] Sent: Tuesday, April 7, 2020 11:48 AM To: Yuan Chun Ding Cc: r-help mailing list Subject: Re: [R] to create a new

Re: [R] to create a new variable based on values in other variables

2020-04-07 Thread Yuan Chun Ding
Hi Bert, your code worked perfect. you always make me learn new R code skills! Thank you so much!! Ding From: Bert Gunter [bgunter.4...@gmail.com] Sent: Tuesday, April 7, 2020 12:53 PM To: Yuan Chun Ding Cc: r-help mailing list Subject: Re: [R] to

[R] help with sqldf

2020-06-28 Thread Yuan Chun Ding
Hi R Users, I tried to use sql in R; test1 works well, library(sqldf) test1 <- sqldf("select * from r where V1 like '%GCCATGTCAGCACACTACC%TGAAACCTTTAACTATTT%'") test2 <- sqldf("select * from r where V1 like markerinfo$flank1[1] ") but I want to store the search content in a markerinfo file as

Re: [R] help with sqldf

2020-06-28 Thread Yuan Chun Ding
Thank you, Sarah, I modified your suggestion a little and it works. Ding -Original Message- From: Sarah Goslee [mailto:sarah.gos...@gmail.com] Sent: Sunday, June 28, 2020 2:01 PM To: Yuan Chun Ding Cc: r-help@r-project.org Subject: Re: [R] help with sqldf [Attention: This email came

[R] boxplots and dotplots by color group 1 and shape group2

2021-09-16 Thread Yuan Chun Ding via R-help
Dear R users, I generated a boxplots in combination of dotplots using the R code below for the attached test file. boxplot(value~score, data = test, outpch = NA, xlab="",ylab="",xaxt='n', cex.lab=1.2, cex.axis=1.2, main="Correlation of SCNV score and SCNV value ") mtext(side=2, "SCNV val

[R] how to include if conditions in dplyr filter function

2021-10-26 Thread Yuan Chun Ding via R-help
Hi R users, I thought the follow R code should work, but I got error, Can you fix my code? Thank you, Ding outlier_tcga_MAD3 <- outlier_tcga %>% filter(n_two >0) %>% mutate(freqMAD3_gain2ratio = N_MAD3_gain2/n_two )%>% if (N_MAD3 < 9) {filter(freqMAD3_gain >=1)} else if (N_MAD3 > n_t

[R] my R code worked well when running the first 1000 lines of R code

2024-06-12 Thread Yuan Chun Ding via R-help
it only generated one column of summary. Do you know why? Thank you, Yuan Chun Ding summary_anno1148ft <- anno1148ft %>% pivot_longer(c(t_depth, t_alt_count, t_alt_ratio), names_to = "measure") %>% group_by(dat, measure) %>% summarize(minimum = min(value,na.rm=T),

Re: [R] my R code worked well when running the first 1000 lines of R code

2024-06-12 Thread Yuan Chun Ding via R-help
down. Thank you, Ding From: CALUM POLWART Sent: Wednesday, June 12, 2024 10:52 AM To: Yuan Chun Ding Cc: r-help@r-project.org Subject: Re: [R] my R code worked well when running the first 1000 lines of R code I sometimes think people on this list are quite rude to posters. I'm afrai

Re: [R] my R code worked well when running the first 1000 lines of R code

2024-06-12 Thread Yuan Chun Ding via R-help
: Rui Barradas Sent: Wednesday, June 12, 2024 11:29 AM To: Yuan Chun Ding ; CALUM POLWART Cc: r-help@r-project.org Subject: Re: [R] my R code worked well when running the first 1000 lines of R code Hello, Inline. Às 19: 03 de 12/06/2024, Yuan Chun Ding via R-help escreveu: > I am sorry that I know

[R] please help generate a square correlation matrix

2024-07-25 Thread Yuan Chun Ding via R-help
Hi R users, I generated a square correlation matrix for the dat dataframe below; dat<-data.frame(g1=c(1,0,0,1,1,1,0,0,0), g2=c(0,1,0,1,0,1,1,0,0), g3=c(1,1,0,0,0,1,0,0,0), g4=c(0,1,0,1,1,1,1,1,0)) library("Hmisc") dat.rcorr = rcorr(as.matrix(dat)) da

Re: [R] please help generate a square correlation matrix

2024-07-25 Thread Yuan Chun Ding via R-help
HI Rui, Thank you for the help! You did not remove a row if zero values exist in both column pair, right? Ding From: Rui Barradas Sent: Thursday, July 25, 2024 11:15 AM To: Yuan Chun Ding ; r-help@r-project.org Subject: Re: [R] please help generate a square correlation matrix Às 17: 39 de

Re: [R] please help generate a square correlation matrix

2024-07-25 Thread Yuan Chun Ding via R-help
.test(tem2[,1],tem2[,2]) r[i, j] <- tmp3$estimate P[i, j] <- tmp3$p.value } } } r<-as.data.frame(r) P<-as.data.frame(P) From: R-help On Behalf Of Yuan Chun Ding via R-help Sent: Thursday, July 25, 2024 11:26 AM To: Rui Barradas ; r-help@r-project.org Subject: Re: [

Re: [R] please help generate a square correlation matrix

2024-07-27 Thread Yuan Chun Ding via R-help
, i], dat[k, j]) : the standard deviation is zero > > > > The NA and warning comes in the 2,4 pair of columns because after > > removing all zero rows in the pair, dat[,4] is all 1's, giving a zero > > in the denominator of the cor() calculation -- again, assum

Re: [R] please help generate a square correlation matrix

2024-07-27 Thread Yuan Chun Ding via R-help
my case, we measured all mutations for all 1000 samples using an exactly same sequencing method, so no issue of never-reporting. I am very grateful for help and comments from Rui, Richard and Bert!! Ding From: Bert Gunter Sent: Saturday, July 27, 2024 4:50 PM To: Yuan Chun Ding Cc: Richard

Re: [R] a fast way to do my job

2024-08-09 Thread Yuan Chun Ding via R-help
Dear R users, I am running the following code below, the gem751be.rpkm is a dataframe with dim of 751 samples by 35164 variables, 73 phenotypic variables in the furst to 73rd column and 35091 genomic variables or genes in the 74th to 35164th columns. What I need to do is to calculate the res

Re: [R] a fast way to do my job

2024-08-10 Thread Yuan Chun Ding via R-help
0.99. I have not found the reason. Thanks, Ding From: Bert Gunter Sent: Friday, August 9, 2024 7:11 PM To: Ben Bolker Cc: Yuan Chun Ding ; r-help@r-project.org Subject: Re: [R] a fast way to do my job Better idea, Ben! It would work as you might expect it to to produce the same results as the

Re: [R] a fast way to do my job

2024-08-10 Thread Yuan Chun Ding via R-help
after add intercept, all residuals are the same from lm or lm.fit. Ding From: Bert Gunter Sent: Saturday, August 10, 2024 1:00 PM To: Yuan Chun Ding Cc: Ben Bolker ; r-help@r-project.org Subject: Re: [R] a fast way to do my job Probably because you inadvertently ran different models. Without

Re: [R] a fast way to do my job

2024-08-10 Thread Yuan Chun Ding via R-help
You are right. I also just thought about that, no intercept is not applicable to my case. Ding From: Bert Gunter Sent: Saturday, August 10, 2024 1:06 PM To: Yuan Chun Ding Cc: Ben Bolker ; r-help@r-project.org Subject: Re: [R] a fast way to do my job Ah, messages crossed. A no-intercept

Re: [R] a fast way to do my job

2024-08-10 Thread Yuan Chun Ding via R-help
e.rpkm$purity2) then running result2 <- residuals(lm.fit( x= pur2.1, y = dat)); now I am thinking whether an intercept is required or not. Ding From: R-help On Behalf Of Yuan Chun Ding via R-help Sent: Saturday, August 10, 2024 12:30 PM To: Bert Gunter ; Ben Bolker Cc: r-help@r-project.org Subjec