Skip to content

Commit

Permalink
fix symbol IDs Boolean rule when setting unique=TRUE
Browse files Browse the repository at this point in the history
  • Loading branch information
reedliu committed Mar 20, 2023
1 parent 66a79af commit 0279e66
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: genekitr
Type: Package
Title: Gene Analysis Toolkit
Version: 1.1.4
Version: 1.1.5
Authors@R:
c(person(given = "Yunze",
family = "Liu",
Expand Down
48 changes: 27 additions & 21 deletions R/genInfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,22 @@ genInfo <- function(id = NULL,
if( keytype == 'symbol' && 'symbol' %in% colnames(gene_info) ){
sym <- sub[check, "symbol"]
if(any(sym%in%x)){
# if id has summary info, it is firstly considered
if('summary' %in% colnames(sub)){
res <- which(!is.na(sub$summary[check]))
if(length(res) >1) res <- check[which(sym%in%x)]
}else{
# first reserve the identical id
res <- check[which(sym%in%x)]

# if res length >1
if(length(res) >1){
# if id has summary info, it is firstly considered
if('summary' %in% colnames(sub)){
res <- which(!is.na(sub$summary[check]))
if(length(res) >1) res <- check[which(sym%in%x)]
}else{
res <- check[which(sym%in%x)]
}

res <- check[which(sym%in%x)]
if(length(res) >1) res <- c()
}

if(length(res) >1) res <- c()
}
}

Expand Down Expand Up @@ -206,20 +212,20 @@ replace_back <-function(id){
id <- stringr::str_replace_all(id, 'sigma', "\\u03c3" )
}

imerge <- function(x,y,by){
dat = fuzzyjoin::regex_inner_join(x,y,by = by,ignore_case =TRUE)
if(is.null(names(by))){
i = which(colnames(x)==by)
}else{
i = which(colnames(x)==names(by))
}
j = which(colnames(y)==by)+ncol(x)
k = apply(dat,1,function(z){
pracma::strcmpi(z[i],z[j])
})
dat = dat[k,]
return(dat)
}
# imerge <- function(x,y,by){
# dat = fuzzyjoin::regex_inner_join(x,y,by = by,ignore_case =TRUE)
# if(is.null(names(by))){
# i = which(colnames(x)==by)
# }else{
# i = which(colnames(x)==names(by))
# }
# j = which(colnames(y)==by)+ncol(x)
# k = apply(dat,1,function(z){
# pracma::strcmpi(z[i],z[j])
# })
# dat = dat[k,]
# return(dat)
# }

utils::globalVariables(c(":=", "symbol", "uniprot", "input_id", "symbol", "chr", "start", "end",
"strcmpi", "symbol.x", "symbol.y", "symbol_lower", "symbol_upper"))
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<img src="https://jieandze1314-1255603621.cos.ap-guangzhou.myqcloud.com/blog/2022-05-24-043213.png" align="left" width="200"/>

[![CRANstatus](https://www.r-pkg.org/badges/version/genekitr)](https://cran.r-project.org/package=genekitr) [![](https://img.shields.io/badge/devel%20version-1.1.4-green.svg)](https://github.com/GangLiLab/genekitr) [![](https://cranlogs.r-pkg.org/badges/grand-total/genekitr?color=orange)](https://cran.r-project.org/package=genekitr) [![lifecycle](https://img.shields.io/badge/lifecycle-stable-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![CRANstatus](https://www.r-pkg.org/badges/version/genekitr)](https://cran.r-project.org/package=genekitr) [![](https://img.shields.io/badge/devel%20version-1.1.5-green.svg)](https://github.com/GangLiLab/genekitr) [![](https://cranlogs.r-pkg.org/badges/grand-total/genekitr?color=orange)](https://cran.r-project.org/package=genekitr) [![lifecycle](https://img.shields.io/badge/lifecycle-stable-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)

![Alt](https://repobeats.axiom.co/api/embed/e42ba06d30de893670c70324f19398ef0a7c26fa.svg "Repobeats analytics image")

Expand Down

0 comments on commit 0279e66

Please sign in to comment.