renaming LGs

379 views
Skip to first unread message

Kevin

unread,
Apr 4, 2011, 3:48:15 PM4/4/11
to R/qtl discussion
This may be a simple thing to do, but I haven't figured out the right
way to do it yet.

I would like to rename my linkage groups. Rather than going from
largest to smallest, the standard in my organism is to label the
chromosome with a sex locus as I and then go from largest to
smallest... Right now I have my sex locus on lg III.


Therefore I would like to change the names on the linkage groups (to
make plotting them easier).


All I can think of is to output the data, change the chromosome IDs in
excel or a text editor and then reimport the data. There must be a
more elegant way than that!

Cheers,
Kevin

Karl Broman

unread,
Apr 4, 2011, 11:16:32 PM4/4/11
to rqtl...@googlegroups.com
A cross object is stored as a list with components "geno" and "pheno". The "geno portion is stored as a list with each component being a chromosome. The chromosome names are defined via the names of those components. You can change the names and order of those as you wish. Consider the following examples, via the 'hyper' data set.

> data(hyper)
> chrnames(hyper)
[1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10"
[11] "11" "12" "13" "14" "15" "16" "17" "18" "19" "X"
> names(hyper$geno) <- c(19:1, "X")
> chrnames(hyper)
[1] "19" "18" "17" "16" "15" "14" "13" "12" "11" "10"
[11] "9" "8" "7" "6" "5" "4" "3" "2" "1" "X"
> hyper$geno <- hyper$geno[20:1]
> chrnames(hyper)
[1] "X" "1" "2" "3" "4" "5" "6" "7" "8" "9"
[11] "10" "11" "12" "13" "14" "15" "16" "17" "18" "19"

karl

> --
> You received this message because you are subscribed to the Google Groups "R/qtl discussion" group.
> To post to this group, send email to rqtl...@googlegroups.com.
> To unsubscribe from this group, send email to rqtl-disc+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rqtl-disc?hl=en.
>

BD

unread,
Nov 12, 2020, 1:45:59 PM11/12/20
to R/qtl discussion
what about scenario like this?
#rename the linkage groups
> names(hyper$geno) <- c(19,17,16,18,15,1:14, "X")
> chrnames(hyper)
[1] "19" "17" "16" "18" "15" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" [20] "X"

when plotMap again, the linkage groups are arranged in the same order above.
But,how to arrange the linkage groups in order again with the newly assigned id, say [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" [20] "X" ?

Thanks!

Karl Broman

unread,
Nov 12, 2020, 2:12:29 PM11/12/20
to R/qtl discussion
hyper$geno is a list, with each component being a chromosome. Changing names(hyper$geno) changes the chromosomes labels. If you want to reorder them, use [ ].

    hyper$geno <- hyper$geno[c(1:19,"X")]

Note that 1:19 will give the vector of numbers 1,2,3,...,19, but when you add "X" to it they will all get converted to the vector of character strings "1", "2", "3", ..., "19", "X". So this will reorder the components according to their names.

Also note that your first bit of code, changing the names, could be made slightly more compact because the : operator can work in either direction.

    names(hyper$geno) <- c(19:15, 1:14, "X")

karl

BD

unread,
Nov 12, 2020, 2:57:10 PM11/12/20
to R/qtl discussion
Got it, thank you so much!

Joshua Havill

unread,
Jan 19, 2021, 5:56:18 PM1/19/21
to R/qtl discussion
Hi Karl,

I am trying to do something similar (change and sort the names of the linkage groups based upon the physical chromosome they belong to).

The names of the linkage groups were 1 through 10 and ordered based upon size.

chrnames(mapthis.clean) ## Get the names
names(mapthis.clean$geno) <- c(7,8,4,1,2,3,10,9,6,5) ## Change the names based upon the physical chromosome these groups belong too
chrnames(mapthis.clean) ## Check that the names have been changed
mapthis.clean$geno <- mapthis.clean$geno[c(1:10)] ## Sort the groups based upon their names
chrnames(mapthis.clean) ## Check that they've been sorted

Unfortunately, they don't appear to be sorting based upon their names. Any tips?

> chrnames(mapthis.clean)
 [1] "7"  "8"  "4"  "1"  "2"  "3"  "10" "9"  "6"  "5"

Karl Broman

unread,
Jan 19, 2021, 7:09:33 PM1/19/21
to R/qtl discussion
Maybe in the reordering step, use character strings to make sure that they get reordered by name and not by numeric index.

So change this line:

    mapthis.clean$geno <- mapthis.clean$geno[c(1:10)] ## Sort the groups based upon their names

To this:

    mapthis.clean$geno <- mapthis.clean$geno[as.character(1:10)]

karl

havi...@umn.edu

unread,
Jan 19, 2021, 9:10:25 PM1/19/21
to rqtl...@googlegroups.com
Thanks Karl!

-------
Joshua Havill

On Jan 19, 2021, at 6:09 PM, Karl Broman <kbr...@gmail.com> wrote:


To unsubscribe from this group and stop receiving emails from it, send an email to rqtl-disc+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rqtl-disc/79b1e8df-35b5-472f-8e2f-0e9bd09a246an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages